Jan Flikweert
Programmer
Hi all,
I managed to get Speech to Command working in VFP. For that part you can see this is a tip. I faced an issue regarding speaking single digits. The solution was using a prefix: f.e. "Box one", "Box two" etc.
Using single digit's the program selects command buttons with f.e. "1", lablels them and ask your choice. That works, but is not fast.
Kind regards,
Jan Flikweert
I managed to get Speech to Command working in VFP. For that part you can see this is a tip. I faced an issue regarding speaking single digits. The solution was using a prefix: f.e. "Box one", "Box two" etc.
Using single digit's the program selects command buttons with f.e. "1", lablels them and ask your choice. That works, but is not fast.
Kind regards,
Jan Flikweert
Code:
CLOSE ALL
CLEAR ALL
Public oRecognize, oVFPObj,ogrammar,result_command
oVFPObj = Createobject("RCLSpeechInput")
oRecognize = Createobject("SAPI.SpSharedRecoContext")
*oRecognize = Createobject("SAPI.SpInProcRecognizer")
Eventhandler(oRecognize,oVFPObj)
ogrammar = oRecognize.CreateGrammar(1)
oGrammar.DictationLoad
oGrammar.DictationSetState(1)
READ EVENTS
Define Class RCLSpeechInput As Session OlePublic
Implements _ISpeechRecoContextEvents In "C:\WINDOWS\SYSTEM32\SPEECH\COMMON\SAPI.DLL"
Procedure _ISpeechRecoContextEvents_StartStream(StreamNumber As Number, StreamPosition As VARIANT) As VOID;
HELPSTRING "StartStream"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_EndStream(StreamNumber As Number, StreamPosition As VARIANT, StreamReleased As LOGICAL) As VOID;
HELPSTRING "EndStream"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_Bookmark(StreamNumber As Number, StreamPosition As VARIANT, BookmarkId As VARIANT, Options As VARIANT) As VOID;
HELPSTRING "Bookmark"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_SoundStart(StreamNumber As Number, StreamPosition As VARIANT) As VOID;
HELPSTRING "SoundStart"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_SoundEnd(StreamNumber As Number, StreamPosition As VARIANT) As VOID;
HELPSTRING "SoundEnd"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_PhraseStart(StreamNumber As Number, StreamPosition As VARIANT) As VOID;
HELPSTRING "PhraseStart"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_Recognition(StreamNumber As Number, StreamPosition As VARIANT, RecognitionType As VARIANT, Result As VARIANT) As VOID;
HELPSTRING "Recognition"
_VFP.AutoYield=.f.
result_command=Result.PhraseInfo.GetText
Do Case
Case LOWER(result_command) == "one"
Thisformset.Baseform12.Btnctrlmemory1.exe_mmr()
Case LOWER(result_command) = "two"
Thisformset.Baseform12.Btnctrlmemory2.exe_mmr()
Case "three" $ LOWER(result_command)
Thisformset.Baseform12.Btnctrlmemory3.exe_mmr()
Case LOWER(result_command) == "four"
Thisformset.Baseform12.Btnctrlmemory4.exe_mmr()
Case LOWER(result_command) == "five"
Thisformset.Baseform12.Btnctrlmemory5.exe_mmr()
Case LOWER(result_command) == "six"
Thisformset.Baseform12.Btnctrlmemory6.exe_mmr()
Case LOWER(result_command) == "seven"
Thisformset.Baseform12.Btnctrlmemory7.exe_mmr()
Case LOWER(result_command) == "eight"
Thisformset.Baseform12.Btnctrlmemory8.exe_mmr()
Case LOWER(result_command) == "nine"
Thisformset.Baseform12.Btnctrlmemory9.exe_mmr()
Case LOWER(result_command) == "ten"
Thisformset.Baseform12.Btnctrlmemory10.exe_mmr()
Case result_command == "eleven"
Thisformset.Baseform12.Btnctrlmemory11.exe_mmr()
Case result_command == "twelve"
Thisformset.Baseform12.Btnctrlmemory12.exe_mmr()
Case result_command == "thirtheen"
Thisformset.Baseform12.Btnctrlmemory13.exe_mmr()
Case result_command == "fourtheen"
Thisformset.Baseform12.Btnctrlmemory14.exe_mmr()
Case result_command == "15"
Thisformset.Baseform12.Btnctrlmemory15.exe_mmr()
Case result_command == "16"
Thisformset.Baseform12.Btnctrlmemory16.exe_mmr()
Case result_command == "17"
Thisformset.Baseform12.Btnctrlmemory17.exe_mmr()
Case result_command == "18"
Thisformset.Baseform12.Btnctrlmemory18.exe_mmr()
Case result_command == "19"
Thisformset.Baseform12.Btnctrlmemory19.exe_mmr()
Case result_command == "20"
Thisformset.Baseform12.Btnctrlmemory20.exe_mmr()
Case result_command == "21"
Thisformset.Baseform12.Btnctrlmemory21.exe_mmr()
Case result_command == "22"
Thisformset.Baseform12.Btnctrlmemory22.exe_mmr()
Case result_command == "23"
Thisformset.Baseform12.Btnctrlmemory23.exe_mmr()
Case result_command == "24"
Thisformset.Baseform12.Btnctrlmemory24.exe_mmr()
Case result_command == "25"
Thisformset.Baseform12.Btnctrlmemory25.exe_mmr()
Case result_command == "26"
Thisformset.Baseform12.Btnctrlmemory26.exe_mmr()
Case result_command == "27"
Thisformset.Baseform12.Btnctrlmemory27.exe_mmr()
Case result_command == "28"
Thisformset.Baseform12.Btnctrlmemory28.exe_mmr()
Case result_command == "29"
Thisformset.Baseform12.Btnctrlmemory29.exe_mmr()
Case result_command == "30"
Thisformset.Baseform12.Btnctrlmemory30.exe_mmr()
Endcase
_VFP.AutoYield=.t.
Endproc
Procedure _ISpeechRecoContextEvents_Hypothesis(StreamNumber As Number, StreamPosition As VARIANT, Result As VARIANT) As VOID;
HELPSTRING "Hypothesis"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_PropertyNumberChange(StreamNumber As Number, StreamPosition As VARIANT, PropertyName As String, NewNumberValue As Number) As VOID;
HELPSTRING "PropertyNumberChange"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_PropertyStringChange(StreamNumber As Number, StreamPosition As VARIANT, PropertyName As String, NewStringValue As String) As VOID;
HELPSTRING "PropertyStringChange"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_FalseRecognition(StreamNumber As Number, StreamPosition As VARIANT, Result As VARIANT) As VOID;
HELPSTRING "FalseRecognition"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_Interference(StreamNumber As Number, StreamPosition As VARIANT, Interference As VARIANT) As VOID;
HELPSTRING "Interference"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_RequestUI(StreamNumber As Number, StreamPosition As VARIANT, UIType As String) As VOID;
HELPSTRING "RequestUI"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_RecognizerStateChange(StreamNumber As Number, StreamPosition As VARIANT, NewState As VARIANT) As VOID;
HELPSTRING "RecognizerStateChange"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_Adaptation(StreamNumber As Number, StreamPosition As VARIANT) As VOID;
HELPSTRING "Adaptation"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_RecognitionForOtherContext(StreamNumber As Number, StreamPosition As VARIANT) As VOID;
HELPSTRING "RecognitionForOtherContext"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_AudioLevel(StreamNumber As Number, StreamPosition As VARIANT, AudioLevel As Number) As VOID;
HELPSTRING "AudioLevel"
* add user code here
Endproc
Procedure _ISpeechRecoContextEvents_EnginePrivate(StreamNumber As Number, StreamPosition As VARIANT, EngineData As VARIANT) As VOID;
HELPSTRING "EnginePrivate"
* add user code here
Endproc
Enddefine