Hi,
I am using the speech to text based on the Vosk English model to enter commands and parameters into my App.
SpeechToText - Continuous Offline Voice Recognition - Biswajit
I have made a car "speed sentry" app using GPS speed which is completely hands free.
The VR system runs continuously so there is no button pushing prompt required.
When I activate the microphone from the UI the system works perfectly, but if I start the microphone programmatically the engine will read one utterance and then the application freezes.
The relevant code is:
If I enable the startVRTmr the system hangs; if I disable it I can start the VR from the UI "lblVoiceRecognition_Click" and it runs fine.
It does this in both release and debug modes using USB Debugging on my Pixel 6A.
I will post the app in "my creations" once I have it sorted.
Has anyone any ideas on this problem?
I have attached the project excluding the vosk model file which is ~40 MB. This can be downloaded from the alphacephei web site
Regards
Rob
I am using the speech to text based on the Vosk English model to enter commands and parameters into my App.
SpeechToText - Continuous Offline Voice Recognition - Biswajit
I have made a car "speed sentry" app using GPS speed which is completely hands free.
The VR system runs continuously so there is no button pushing prompt required.
When I activate the microphone from the UI the system works perfectly, but if I start the microphone programmatically the engine will read one utterance and then the application freezes.
The relevant code is:
B4X:
'-----------------------------------------------------------------------------------------
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout") ...
vrStartTimer.Initialize("startVRTmr", 15000)
vrStartTimer.Enabled = True
End Sub
'-----------------------------------------------------------------------------------------
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
If Permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
If Result Then CallSub(Starter, "StartGPS")
End If
If Permission = Starter.rp.PERMISSION_RECORD_AUDIO Then
If Result Then
ProgressDialogShow2("Extracting voice model...",False)
If File.IsDirectory(File.DirInternal, model_folder_name) Then
ProgressDialogHide
#If DEBUGGING
Log("Model found")
#End If
vrInit
Else
#If DEBUGGING
Log("Model not found")
#End If
If File.Exists(File.DirInternal, model_zip_name) Then
#If DEBUGGING
Log("Model zip found. Unzipping...")
#End If
Dim ar As Archiver
ar.AsyncUnZip(File.DirInternal, model_zip_name,File.DirInternal,"unzip")
Else
#If DEBUGGING
Log("Model zip not found. Copying...")
#End If
Wait For (File.CopyAsync(File.DirAssets, model_zip_name, File.DirInternal, model_zip_name)) Complete (Success As Boolean)
If Success Then
#If DEBUGGING
Log("Model zip unzipping...")
#End If
Dim ar As Archiver
ar.AsyncUnZip(File.DirInternal,model_zip_name,File.DirInternal,"unzip")
Else
Toast.TMClearAndShow("Failed to extract model", True, True)
End If
End If
End If
Else
Toast.TMClearAndShow("Microphone access needed", True, True)
End If
End If
End Sub
'-----------------------------------------------------------------------------------------
Private Sub vrInit
VoiceRecognitionOn = False
STT.Initialize("STT", File.DirInternal&"/"&model_folder_name)
End Sub
'-----------------------------------------------------------------------------------------
Private Sub startVRTmr_Tick
vrStartTimer.Enabled = False
lblVoiceRecognition_Click
End Sub
'-----------------------------------------------------------------------------------------
Private Sub lblVoiceRecognition_Click
If VoiceRecognitionOn = False Then
VoiceRecognitionOn = True
sentenceText = ""
STT.prepareMicrophone("")
Else
lblVoiceRecognition.Text = ""
If STT.stop Then
Toast.TMClearAndShow("Voice Recognition Off", False, True)
Else
Toast.TMClearAndShow("Voice Recognition Failed to Stop", True, True)
End If
VoiceRecognitionOn = False
End If
lblPartialText.Visible = False
showPartialText = False
End Sub
If I enable the startVRTmr the system hangs; if I disable it I can start the VR from the UI "lblVoiceRecognition_Click" and it runs fine.
It does this in both release and debug modes using USB Debugging on my Pixel 6A.
I will post the app in "my creations" once I have it sorted.
Has anyone any ideas on this problem?
I have attached the project excluding the vosk model file which is ~40 MB. This can be downloaded from the alphacephei web site
VOSK Models
Accurate speech recognition for Android, iOS, Raspberry Pi and servers with Python, Java, C#, Swift and Node.
alphacephei.com
Regards
Rob