npSapi plugin

About this plugin

This plugin allow us to use the Microsoft SAPI from our applications and therefore reproduce text to speech. The plugin can retrieve the system available voices and allow us to reproduce text to speech using any of the available voices. Also the plugin inform us when the text to speech starts and when the text to speech ends using their provided events/subroutines.

Thirparty

This plugin are imposible without the aid of this people:

Thanks a lot!

Plugin actions index

npSapiCreate

Create a new instance of an Sapi object. The result variable store the numeric ID of the new created Sapi object instance. You need this ID on other plugins actions.

↑↑

npSapiDestroy

Destroy a previously created instanace of an Sapi object. The result variable store "True" if everything is OK, or "False" if not. In this last case the [LastError] contain information about the error.

↑↑

npSapiDestroyAll

Destroy all previously created instances of Sapi objects.

↑↑

npSapiPlay

Resume (if paused) or start to reproduce the provided text with the currently used voice.

↑↑

npSapiPause

Pause the current text to speech reproduction.

↑↑

npSapiStop

Stop the current text to speech reproduction.

↑↑

npSapiIsPaused

Find if the current text to speech reproduction is paused or not.

↑↑

npSapiGetVoices

Retrieve the system available voices to be used when reproduce text to speech.

↑↑

npSapiSetVoice

Set an specific voice to be used when reproduce text to speech.

↑↑

npSapiTextToWav

Converts and store the provided text into the specified WAV file. Note that, since this task is does in a synchronous way, the application can be freezen during the conversion on larger texts.

↑↑

npOnSapiStart

Set a subroutine to be execute when a text to speech reproduction starts.

↑↑

npOnSapiEnd

Set a subroutine to be execute when a text to speech reproduction ends.

↑↑

npOnSapiWord

Set a subroutine to be execute when a word is speeched in the reproduction. The Character position variable store the current character position in the text to be reproduced. The Length variable stores the total length of the reproduced word.

↑↑

npOnSapiSentence

Set a subroutine to be execute when a sentence is speeched in the reproduction. The Character position variable store the current character position in the text to be reproduced. The Length variable stores the total length of the reproduced sentence.

↑↑

Action errors subroutine

All the NeoPlugins deal with errors in the same way that VisualNeo does: when the plugin found an action error the [LastError] variable store information about the error, so you can take care about this variable when execute an action.

But all the NeoPlugins also incorporate an advanced way to deal with possible action errors. You can define a subroutine named OnNeoPluginActionError in order to be executed when some action error are found and you can use this variables inside:

Note that this error handling subroutine are shared for all the NeoPlugins, so you no need to specify a subroutine for every plugin you use in your publication because the same subroutine are recognized and automagically used by every NeoPlugin. Below you can view a sample of this subroutine code:

:OnNeoPluginActionError
  AlertBox "NeoPlugin Error" "Error [LastError] in plugin: [PluginName]"
Return

Also note that the use of this NeoPlugins error handling subroutine is completelly optional. You can continue using the [LastError] variable as usual and even use the both methods at the same time.

↑↑