iOS Question Wait for TTS to finish.

John Sturt

Active Member
Licensed User
Longtime User
Hello All
The following code is to demonstrate a problem i am having
I need to be able to wait until it finishes the current speech.
The code below does not work it will hang or produce no speech at all.
I use Voiceover on my device i assume that has a bearing on the matter.

B4X:
'Code module
#Region  Project Attributes
   #ApplicationLabel: B4i Example
   #Version: 1.0.0
   'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
   #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
   #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#End Region

Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Public app As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Dim phone1 As Phone
   Dim tts1 As TTS
   Dim ttsfin As Boolean = False
   
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   NavControl.ShowPage(Page1)
tts1.Initialize ("TE")
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   
End Sub


private Sub Appplication_Active
   For x=0 To 25
     ttsfin = False

   tts1.speak("This should wait for the line to finish speaking "&x,False)

   Do While ttsfin = False
     Loop

   Next

End Sub


Sub TE_Complete (tex As String)
   ttsfin = True
End Sub
 
Top