I get the string from Voice Recognition, and Speak using TTS, it has a error!
The Source Here:
Any help will be appreciate it.
B4X:
I/SpeechServiceRecognizer(14081): SpeechServiceRecognizer(), clientId=VS 1.6.0 os=[Android 2.2 Ideos]
I/GoogleRecognitionService(14081): ssfe url=http://www.google.com/m/voice-search
I/AudioService( 123): AudioFocus abandonAudioFocus() from android.media.AudioManager@43ac6740
W/ActivityManager( 123): Duplicate finish request for HistoryRecord{43f01158 com.google.android.voicesearch/.IntentApiActivity}
W/B4A (14331): sending message to waiting queue (OnActivityResult)
W/B4A (14331): running waiting messages (1)
D/wpa_supplicant( 177): wpa_driver_priv_driver_cmd RSSI-APPROX len = 4096
D/wpa_supplicant( 177): wpa_driver_priv_driver_cmd MyHa2 rssi -48 len = 15, 15
D/wpa_supplicant( 177): wpa_driver_priv_driver_cmd LINKSPEED len = 4096
D/wpa_supplicant( 177): wpa_driver_priv_driver_cmd LinkSpeed 54 len = 12, 12
V/TtsService(13988): TtsService.onCreate()
I/ActivityManager( 123): Start proc com.svox.pico for content provider com.svox.pico/.providers.SettingsProvider: pid=14349 uid=10017 gids={}
I/TTS received: (14331): hello
E/B4A (14331): main_vr_result (java line: 406)
I/ActivityThread(14349): Publishing provider com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider
E/B4A (14331):
E/B4A (14331): java.lang.RuntimeException: Error speaking text.
E/B4A (14331): at anywheresoftware.b4a.obejcts.TTS.Speak(TTS.java:45)
E/B4A (14331): at texttospeech.egg.planet.main._vr_result(main.java:406)
E/B4A (14331): at java.lang.reflect.Method.invokeNative(Native Method)
E/B4A (14331): at java.lang.reflect.Method.invoke(Method.java:521)
E/B4A (14331): at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
E/B4A (14331): at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
E/B4A (14331): at anywheresoftware.b4a.phone.Phone$VoiceRecognition$1.ResultArrived(Phone.java:903)
E/B4A (14331): at anywheresoftware.b4a.BA$4.run(BA.java:451)
E/B4A (14331): at anywheresoftware.b4a.BA.setActivityPaused(BA.java:366)
E/B4A (14331): at texttospeech.egg.planet.main$ResumeMessage.run(main.java:190)
E/B4A (14331): at android.os.Handler.handleCallback(Handler.java:587)
E/B4A (14331): at android.os.Handler.dispatchMessage(Handler.java:92)
E/B4A (14331): at android.os.Looper.loop(Looper.java:123)
E/B4A (14331): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/B4A (14331): at java.lang.reflect.Method.invokeNative(Native Method)
E/B4A (14331): at java.lang.reflect.Method.invoke(Method.java:521)
E/B4A (14331): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/B4A (14331): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/B4A (14331): at dalvik.system.NativeStart.main(Native Method)
E/B4A (14331): java.lang.RuntimeException: Error speaking text.
The Source Here:
B4X:
Sub Process_Globals
Dim VR As VoiceRecognition
Dim TTS1 As TTS
'Dim pw As PhoneWakeState ' keep screen on
End Sub
Sub Globals
Dim barPitch As SeekBar
Dim barSpeechRate As SeekBar
Dim btnSpeak As Button
Dim EditText1 As EditText
Dim spnrLanguages As Spinner
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
If FirstTime Then
VR.Initialize("VR")
TTS1.Initialize("TTS1")
End If
Activity.LoadLayout("1")
If VR.IsSupported Then
ToastMessageShow("Voice recognition is supported.", False)
Else
ToastMessageShow("Voice recognition is not supported.", True)
End If
spnrLanguages.AddAll(Array As String("en", "fr", "de"))
End Sub
Sub Button1_Click
VR.Listen 'calls the voice recognition external activity
End Sub
Sub VR_Result (Success As Boolean, Texts As List)
If TTS1.IsInitialized = False Then
TTS1.Initialize("TTS1")
End If
If Success = True Then
'ToastMessageShow(Texts.Get(0), True)
EditText1.Text=Texts.Get(0)
If EditText1.Text.Length > 0 Then
TTS1.Speak(EditText1.Text, True)
EditText1.SelectAll
End If
'TTS1.Speak(Texts.Get(0), True)
Else
Msgbox("Voice recognition Failed.", "")
End If
End Sub
Sub TTS1_Ready (Success As Boolean)
If Success Then
'enable all views
For i = 0 To Activity.NumberOfViews - 1
Activity.GetView(i).Enabled = True
Next
'btnSpeak_Click 'play first sentence
Else
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 btnSpeak_Click
If EditText1.Text.Length > 0 Then
TTS1.Speak(EditText1.Text, True)
EditText1.SelectAll
End If
End Sub
Sub barSpeechRate_ValueChanged (Value As Int, UserChanged As Boolean)
If UserChanged Then
TTS1.SpeechRate = Value / 10
End If
End Sub
Sub barPitch_ValueChanged (Value As Int, UserChanged As Boolean)
If UserChanged Then
TTS1.Pitch = Value / 10
End If
End Sub
Sub spnrLanguages_ItemClick (Position As Int, Value As Object)
If btnSpeak.Enabled = False Then Return
If TTS1.SetLanguage(Value, "") = False Then
ToastMessageShow("Language data not found.", True)
Return
End If
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select Msgbox2("Do you want exit app?","WARNING","Yes","","No",Null)
Case DialogResponse.POSITIVE
'pw.ReleaseKeepAlive ' keep screen on
Activity.Finish
Case Else
Return True
End Select
'Return True 'Consume the Back key and don't allow Android to process it by iteself
End If
End Sub
Any help will be appreciate it.