iOS Question TTS Problem

khwarizmi

Active Member
Licensed User
Longtime User
Hi all

I wrote this code for TTS, but it is not working:

B4X:
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

End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    Dim tts1 As TTS
    tts1.Initialize("TTS1")
    tts1.SpeechRate = 0.5
    tts1.SetLanguage("en-US")
    tts1.Speak("Hello word",True)
End Sub

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

Private Sub Application_Background
    
End Sub
 

hatzisn

Well-Known Member
Licensed User
Longtime User
Maybe you should try moving this part

B4X:
 Dim tts1 As TTS

In process Globals
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Also change the language definition just to "en"
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Did you try both suggestions? You can always also go to settings in the device to check the settings of the TTS. Also you may also check the sound volume of the device.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Beside previous advice try also to comment the speechrate line
 
Upvote 0

khwarizmi

Active Member
Licensed User
Longtime User
I tried both suggestions and the sound volume, Perhaps that was the settings of the TTS.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Did you try also commenting the speechrate line?
 
Upvote 0

khwarizmi

Active Member
Licensed User
Longtime User
yes, but also not working. I will try also the other setting.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Keep ALL the changes I mentioned and then check if it speaks and if it doesn't it is a setting or you do not run with the latest iOS in your device (I think TTS was introduced in iOS 9). Maybe you should check both the iOS version and the TTS settings.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Full example:
B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private tts As TTS
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)
   tts.Initialize("tts")
End Sub

Sub Page1_Click
   tts.Speak("test", False)
End Sub

Sub tts_Complete (Text As String)
   
End Sub

If it doesn't work then make sure that the device is not muted or the volume is too low.
 
Upvote 0

khwarizmi

Active Member
Licensed User
Longtime User
upload_2019-10-20_9-30-7.gif
thanks a lot.
so the problem is not in my code. 100% of the device settings.
 
Upvote 0
Top