B4J Programming Press on the image to return to the main documentation page.

jSpeechLib

Written by Andrew Graham

This particular library shows that it is possible for a B4J Java library to access a Windows COM or ActiveX object
using COM Interop via a .NET Framework library. In this case the COM object is the MS Speech Object Library.

This library uses the JNA libraries to call native code methods in a .NET library that have been exported by UnmanagedExports
written by Robert Giesecke.

The JNA libraries are licensed under the LGPL, version 2.1 or later, and (from version 4.0 onward)
also the Apache Software License, version 2.0

This library is therefore also licensed under those licences.

UnmanagedExports is licensed by Robert Giesecke under the MIT License but as the managed dll modified by its' use
contains none of the UnmanagedExports code I believe this license applies only to the actual use of UnmanagedExports.
http://opensource.org/licenses/mit-license.php

List of types:

SpeechLib

SpeechLib

The SpeechLib object allows access to the methods of a C# MSSpeech.dll library that has been processed by
the UnmanagedExports NuGGet written by Robert Giesecke to make it callable from a B4J Java library via JNA.
https://www.nuget.org/packages/UnmanagedExports

The C# library exposes the Microsoft COM Speech Object Library.

Events:

None

Members:


  ClearFlags

  DotNetLibraryName As String

  DotNetLibraryVersion As Double

  EndedSentence As Boolean [read only]

  EndedSpeaking As Boolean [read only]

  EndedWord As Boolean [read only]

  ExceptionFlag As Boolean [read only]

  ExceptionMsg As String [read only]

  GetVoiceName (voice As Int) As String

  Initialize

  NumberOfVoices As Int [read only]

  Pause

  Resume

  SayASync (text As String)

  SaySync (text As String)

  SentenceCount As Int [read only]

  Skip (numitems As Int)

  SpeechRate As Int

  StartedSpeaking As Boolean [read only]

  Version As Double [read only]

  Voice As Int

  Volume As Int

  WordCount As Int [read only]

Members description:

ClearFlags
This will clear all the flags and counters of the Speech library.
StartedSpeaking, EndedSpeaking, EndedSentence, EndedWord are all set False.
SentenceCount and WordCount are set to 0.
DotNetLibraryName As String
Returns the name of the .NET MSSpeech library.
DotNetLibraryVersion As Double
Returns the version number of the .NET MSSpeech library.
EndedSentence As Boolean [read only]
Returns True if the voice has ended a sentence.
Reading this property will reset the flag to False so that the end of a subsequent sentence may be detected.
EndedSpeaking As Boolean [read only]
Returns True if the voice has ended speaking.
EndedWord As Boolean [read only]
Returns True if the voice has ended a word.
Reading this property will reset the flag to False so that the end of a subsequent word may be detected.
In practice this will be of little use as in the absence of events this flag will be too rapidly set again
to be of any real use.
ExceptionFlag As Boolean [read only]
Returns True if an Exception occurred while speaking.
ExceptionMsg As String [read only]
Returns the message of whatever Exception occurred while speaking.
GetVoiceName (voice As Int) As String
Returns the name of the voice given the index number into the number of voices.
Initialize
Initialise an instance of our .NET library Interface so we can call its' methods.
NumberOfVoices As Int [read only]
Gets the number of voices installed on the system.
Pause
Pauses speaking. Note that this might take a second or so to take effect.
Pauses are additive so several pauses need the same number of Resumes before speaking starts again.
Also be aware that if a Pause is in effect before SaySync is invoked then the application will lock up as the speech is paused
and cannot finish and return to the application.
Resume
Resumes speech from a Pause.
SayASync (text As String)
Speaks the text given and returns immediately. The B4J application will run in parallel with the voice thread.
The sentence and word counts are updated as they happen.
SaySync (text As String)
Speaks the text given and blocks until finished. The B4J application will be frozen until speech ends.
The sentence and word counts are updated a short time after SaySync returns so are not valid immediately.
SentenceCount As Int [read only]
Returns the number of sentences spoken so far. This count is set to 0 on ClearFlags, SaySync or SayAsync.
Note that after SaySync returns this may not be immediately valid as it seems to take a short while to update.
Skip (numitems As Int)
Skips forward or backward the given number of sentences. Forward if Number is positive, backward if negative.
SpeechRate As Int
Gets or sets a value between -10 and +10 determining the rate of speech. Default is 0
StartedSpeaking As Boolean [read only]
Returns True if the voice has started speaking.
Version As Double [read only]
Returns the version number of the library.
Voice As Int
Gets or sets a value between 0 and the number of voices installed on the system less one.
Selects which voice to use. Default is 0 - the first voice.
Volume As Int
Gets or sets a value between 0 and 100 determining The volume at which the speech is spoken.
Default is 100 - maximum volume
WordCount As Int [read only]
Returns the number of words spoken so far. This count is set to 0 on ClearFlags, SaySync or SayAsync.
Note that after SaySync returns this may not be immediately valid as it seems to take a short while to update.
Top