SPLat Logo

# SpeakText (t:Text{, L:Language}{, c:Country}{, q:ClearQueue}) hash function

NOTICE: Our web site is being updated, but is currently experiencing extreme slowness due to host issues. Please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map
SPLat will be shut down for the Christmas Holiday season from Friday 20 December 2024 through Tuesday 7 January 2025. We will check emails periodically and will continue to process orders but at a slower pace. Santa hat

# SpeakText (t:Text{, L:Language}{, c:Country}{, q:ClearQueue}) hash function

Please note the Android and Windows implementations of SimpleHMI have been deprecated.  Both were little used and have been superseded by the HMI series of SPLat Controllers.

Valid for use with hash command: HMI Arguments may be specified as Name:Value Pairs

Implemented on the following platforms: Android, Windows (altered functionality).

Speaks out loud the supplied Text. See OldSpeakNumb for speaking numbers. Does not speak out loud in Windows; instead it shows a dismissible text box.

Language is the language to be spoken, and is specified as two lower case letters. Language codes. The target language must be installed in the Android device.

Country is the country specific variant ("dialect"). This is specified as two upper case letters. Country codes.

ClearQueue, if a non-zero number will result in any previously queued text being deleted. Otherwise the text for successive Speak functions is queued up.

Any of the arguments can be empty (with a necessary comma). If language/country are never specified the default setting on the Android device will apply.

Example:

The following program contains 3 calls to SpeakText(). The first call, during initialisation, sets language and country, with no text. The second call, in the evHelloWorld event handler subroutine has no ClearQueue flag. The third call has ClearQueue set (non-zero). This results in the spoken message "stomping on" any other speech that's in train. The example also illustrates the use of the OldSpeakNumb hash function. The program is written for an MS121 with a BT-TTL5 Bluetooth adaptor.



# Open_Serial User(38400,8,N)
GoSub HMI_Connect ;Paint the initial screen
# HMI ConnectEvent(HMI_Connect) ;Declare the handler for the Connected event
# HMI SpeakText(t:"", L:"en", c:"AU",) ;Set the language/country for speech
LaunchTask HeartBeat ;Blink an output to show we are alive
LaunchTask Crash ;Catch an input, crash to get back control of serial port
RunTasksForever

;Connected event: Paint the screen
HMI_Connect:
# HMI Reset() Cls() HideAllButtons()
# HMI ButtonEvent(, 0.25, 0.2, 3, 0.6, "Hello World", evHelloWorld)
# HMI ButtonEvent(, 0.5, 0.2, 3, 0.6, "How are you?", evHowRU)
# HMI ButtonEvent(, 0.75, 0.2, 3, 0.6, "Count", evCount)
Return

evHelloWorld:
# HMI SpeakText(t:"Hello world")
Return

evHowRU:
# HMI SpeakText("How are you?",,,1) ;Will pre-empt previous speeches.
Return

evCount:
# HMI SpeakText(t:"Count is ") SpeakNumb(f(*fCount, 5, 1))
fRecallW fCount
fLoadQ 0.1
fAdd
fStore fCount
Return
fCount defFLOAT
********************* Minor stuff ***************************************************
;Blink an output to signal the program is running
HeartBeat:
On 8
Pause 1
Off 8
Pause 25
GoTo HeartBeat

;Deliberately crash the program to get back control of the serial port, so SPLat/PC can connect.
Crash: WaitOnK 12
Here GoSub Here