Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private tts As TTS
Type sortable(locale As String, voice As Object)
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
If FirstTime Then
tts.Initialize("tts")
Wait For TTS_Ready (Success As Boolean)
Log(Success)
End If
Dim jo As JavaObject = tts
Dim voices() As Object = jo.RunMethodJO("getVoices", Null).RunMethod("toArray", Null)
Dim sortlist As List
sortlist.Initialize
For Each voice As JavaObject In voices
Dim locale As String = voice.RunMethod("getLocale", Null)
Dim s As sortable
s.locale = locale
s.voice = voice
sortlist.Add( s )
Next
sortlist.SortType( "locale", True)
Dim lv As ListView
lv.Initialize("lv")
Activity.AddView(lv, 0%x, 0%y, 100%x,100%y)
For Each o As sortable In sortlist
Dim voice As JavaObject = o.voice
Dim name As String = voice.RunMethod("getName", Null)
lv.AddSingleLine2( o.locale & " | " & name, voice )
Next
End Sub
Sub lv_ItemClick (Position As Int, Value As Object)
Dim jo As JavaObject = tts
jo.RunMethod("setVoice", Array(Value))
tts.Speak("This is a test of my new voice", False)
End Sub