'-----------------------------------------------------------------------------------------
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