#Region Project Attributes
#ApplicationLabel: tstSpeech
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 10
#PlistExtra:<key>NSSpeechRecognitionUsageDescription</key><string>More information here...</string>
#PlistExtra:<key>NSMicrophoneUsageDescription</key><string>Speech recognition</string>
#End Region
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
Dim speech As SpeechRecognition
Dim myPhone As Phone
Dim tmr As Timer
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)
speech.Initialize("speech")
'awaits 100 millisecs before start recording
tmr.Initialize("tmr",100)
tmr.Enabled = True
End Sub
Private Sub tmr_Tick
speech.StartRecording(True)
tmr.Enabled = False
End Sub
Private Sub speech_Result (Success As Boolean, IsFinal As Boolean, Texts As List)
If Success Then
Log(Texts.get(0))
'example of called sub
doVibrate
Else
End If
End Sub
Private Sub doVibrate
Sleep(100)
myPhone.Vibrate
End Sub
Private Sub speech_AuthorizationStatusChanged (Status As Int)
If speech.IsAuthorized Then
Dim lang As String = "en"
If speech.SetLanguage(lang) = False Then
Log("Speech Recognition not available.")
Else
Log("ready")
End If
Else
Log("Not authorized...")
End If
End Sub