I'm trying to add some TextToSpeech to some notifications.
In order to maintain the whole project as clean as possible I'd like to place the TTS routines in a code module, but it seems it doesn't work.
The code of the module is as follow:
(the code is a bit 'dirt' due my testing and trying)
The Sub TTS1_Ready is never fired...
If I copy&paste that same code in an activity, it works...
In order to maintain the whole project as clean as possible I'd like to place the TTS routines in a code module, but it seems it doesn't work.
The code of the module is as follow:
B4X:
'Code module
Sub Process_Globals
Dim TTS1 As TTS
Dim TheMsg As String
Dim TTsReady As Boolean
End Sub
Sub StartUp()
TTS1.Initialize("TTS1")
Log("TTS Init")
End Sub
Sub SpeakThis(msg As String)
TheMsg = msg
If TTS1.IsInitialized = False Then
TTS1.Initialize("TTS1")
Else
If msg<>"" Then
Log("MSG=" & TTsReady & " ->" & TheMsg)
If TTsReady Then TTS1.Speak(TheMsg, True)
End If
End If
End Sub
Sub TTS1_Ready (Success As Boolean)
If Success Then
If TheMsg<>"" Then
Log("MSG=" & TheMsg)
TTS1.Speak(TheMsg, True)
End If
End If
TTsReady=Success
End Sub
(the code is a bit 'dirt' due my testing and trying)
The Sub TTS1_Ready is never fired...
If I copy&paste that same code in an activity, it works...