Kevin Hartin Active Member Licensed User Longtime User Mar 30, 2019 #1 Hi all, I have been hacking my way through building an app with offline maps, a database of markers and alerts as a marker comes near. It is all working fine as I post an alert to the screen with all the relevant information using ToastMessageShow. What I want to add as an option is a verbal alert such as "Fuel 100 metres ahead". I have been playing around with a sample app and have stored "100", "Metres" and "Ahead" into a soundpool thing and want to play them back sequentially, one after the other. Question is Should I use "Wait for" or am I better storing an array of Sleep values for each of the sound files? I am really new to this sort of programming, so don't really understand what I am waiting for with respect to SP.Play Code: Sub Button8_Click PlayId5 = SP.Play(LoadId5, 1, 1, 1, 0, 1) Sleep(1000) PlayId6 = SP.Play(LoadId6, 1, 1, 1, 0, 1) Sleep(600) PlayId7 = SP.Play(LoadId7, 1, 1, 1, 0, 1) End Sub Thanks in advance, Kev Attachments SoundPool.zip SoundPool.zip 158.8 KB · Views: 688
Hi all, I have been hacking my way through building an app with offline maps, a database of markers and alerts as a marker comes near. It is all working fine as I post an alert to the screen with all the relevant information using ToastMessageShow. What I want to add as an option is a verbal alert such as "Fuel 100 metres ahead". I have been playing around with a sample app and have stored "100", "Metres" and "Ahead" into a soundpool thing and want to play them back sequentially, one after the other. Question is Should I use "Wait for" or am I better storing an array of Sleep values for each of the sound files? I am really new to this sort of programming, so don't really understand what I am waiting for with respect to SP.Play Code: Sub Button8_Click PlayId5 = SP.Play(LoadId5, 1, 1, 1, 0, 1) Sleep(1000) PlayId6 = SP.Play(LoadId6, 1, 1, 1, 0, 1) Sleep(600) PlayId7 = SP.Play(LoadId7, 1, 1, 1, 0, 1) End Sub Thanks in advance, Kev
E emexes Expert Licensed User Longtime User Mar 30, 2019 #2 Is there a reason for not using Text To Speech? I just gave it a quick burl, seems to work ok (even speaks "BP" and "7-Eleven" correctly). I thought maybe you were wary of relying on a wireless data connection during mobile/vehicular use, but I just tested it here in airplane mode and with Wifi off, and it still speaks ok (although there is a slim chance that it caches recent TTS conversions, so... best test that a bit harder). Code: Sub Process_Globals Dim TTS1 As TTS End Sub Sub Globals End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Layout1") 'just a simple button (Button1) End Sub Sub TTS1_Ready (Success As Boolean) Log("TTS1_Ready " & Success) If Success = False Then Msgbox("Error initializing TTS engine.", "") End If End Sub Sub Activity_Resume If TTS1.IsInitialized = False Then TTS1.Initialize("TTS1") End If End Sub Sub Activity_Pause (UserClosed As Boolean) TTS1.Release End Sub Sub Button1_Click Log("Fuel ahoy!") TTS1.Speak("Fuel ahead in 100 metres.", False) TTS1.Speak("BP petrol station on left in 120 metres.", False) TTS1.Speak("7-Eleven petrol station ahead in 140 metres.", False) TTS1.Speak("Caltex petrol station on right in 234 metres.", False) End Sub Upvote 0
Is there a reason for not using Text To Speech? I just gave it a quick burl, seems to work ok (even speaks "BP" and "7-Eleven" correctly). I thought maybe you were wary of relying on a wireless data connection during mobile/vehicular use, but I just tested it here in airplane mode and with Wifi off, and it still speaks ok (although there is a slim chance that it caches recent TTS conversions, so... best test that a bit harder). Code: Sub Process_Globals Dim TTS1 As TTS End Sub Sub Globals End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Layout1") 'just a simple button (Button1) End Sub Sub TTS1_Ready (Success As Boolean) Log("TTS1_Ready " & Success) If Success = False Then Msgbox("Error initializing TTS engine.", "") End If End Sub Sub Activity_Resume If TTS1.IsInitialized = False Then TTS1.Initialize("TTS1") End If End Sub Sub Activity_Pause (UserClosed As Boolean) TTS1.Release End Sub Sub Button1_Click Log("Fuel ahoy!") TTS1.Speak("Fuel ahead in 100 metres.", False) TTS1.Speak("BP petrol station on left in 120 metres.", False) TTS1.Speak("7-Eleven petrol station ahead in 140 metres.", False) TTS1.Speak("Caltex petrol station on right in 234 metres.", False) End Sub
Kevin Hartin Active Member Licensed User Longtime User Mar 30, 2019 #3 Burl... Aussie, Aussie, Aussie I didn't even know about text to speech, will have a crack tomorrow. What voice/accents are used in this? Can those be changed? I thought that I might get s friendly Samoan voice to record the word bites I needed. Kev Upvote 0
Burl... Aussie, Aussie, Aussie I didn't even know about text to speech, will have a crack tomorrow. What voice/accents are used in this? Can those be changed? I thought that I might get s friendly Samoan voice to record the word bites I needed. Kev
hatzisn Expert Licensed User Longtime User Mar 30, 2019 #4 This thread will be helpful to you with TTS. It includes a lot of functions to do almost what ever you wish. https://www.b4x.com/android/forum/threads/ttsfunctions.94306/ Upvote 0
This thread will be helpful to you with TTS. It includes a lot of functions to do almost what ever you wish. https://www.b4x.com/android/forum/threads/ttsfunctions.94306/
E emexes Expert Licensed User Longtime User Mar 30, 2019 #5 Kevin Hartin said: I didn't even know about text to speech Click to expand... There was another person recently who was using the text-to-speech module to output to files; not quite sure why. But if you need to know 100% that the speech is there when you need it, and not possibly relying upon internet connectivity, then that could be something to look at. Android Question: SynthesizeToFile and text length Kevin Hartin said: What voice/accents are used in this? Can those be changed? Click to expand... I think it defaults to your phone's locale setting, eg: Australia = English. But the voice I hear has an Australian accent, so perhaps it is more fine-grained than just the language. It can be changed to other languages; I quite like that it can speak English text with a French accent. Kevin Hartin said: I thought that I might get s friendly Samoan voice to record the word bites I needed. Click to expand... That sounds more like you'll have to revert back to your sound-bite-recording method that you spoke of originally. Which is what they did with the TomTom GPS voices, and had the advantage that you could change the words too, eg, the royal voice saying: "in 100 metres, one will reach one's destination". Minor digression: There was a speech synthesizer for the Apple II called SAM (Software Automatic Mouth) which would let you write in phonemes and tweak each one individually - you could get some surprisingly good-sounding accents out of that one. Upvote 0
Kevin Hartin said: I didn't even know about text to speech Click to expand... There was another person recently who was using the text-to-speech module to output to files; not quite sure why. But if you need to know 100% that the speech is there when you need it, and not possibly relying upon internet connectivity, then that could be something to look at. Android Question: SynthesizeToFile and text length Kevin Hartin said: What voice/accents are used in this? Can those be changed? Click to expand... I think it defaults to your phone's locale setting, eg: Australia = English. But the voice I hear has an Australian accent, so perhaps it is more fine-grained than just the language. It can be changed to other languages; I quite like that it can speak English text with a French accent. Kevin Hartin said: I thought that I might get s friendly Samoan voice to record the word bites I needed. Click to expand... That sounds more like you'll have to revert back to your sound-bite-recording method that you spoke of originally. Which is what they did with the TomTom GPS voices, and had the advantage that you could change the words too, eg, the royal voice saying: "in 100 metres, one will reach one's destination". Minor digression: There was a speech synthesizer for the Apple II called SAM (Software Automatic Mouth) which would let you write in phonemes and tweak each one individually - you could get some surprisingly good-sounding accents out of that one.
Kevin Hartin Active Member Licensed User Longtime User Apr 2, 2019 #6 Thanks all, I have used Text to Speech, with a nice female Aussie accent. I tried tricking it into pronouncing Samoan place names, but could only get about 40% to work properly. Upvote 0
Thanks all, I have used Text to Speech, with a nice female Aussie accent. I tried tricking it into pronouncing Samoan place names, but could only get about 40% to work properly.