Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Voice triger
#1
Hello guys!
Help please, can I run macros with voice trigger like that- I talk in microphone word, for example "book," and macros is run?
#2
Simplest example. Uses SAPI -Windows speech engine.

But in my tests it rarely recognized words correctly. Maybe I don't speak English correctly, or need some more settings, or need training, or bad sound level, I don't know.

Function Speech_recognition
Code:
Copy      Help
if(getopt(nthreads)>1) ;;allow single instance
,if('Y'=mes("Already running. Exit?" "Speech_recognition" "YN")) EndThread "Speech_recognition"
,ret

typelib SpeechLib {C866CA3A-32F7-11D2-9602-00C04F8EE628} 5.4
SpeechLib.SpSharedRecoContext src._create
ISpRecoContext isrc=+src
;isrc.SetInterest ;;default - only Recognition event
ISpRecoGrammar g
long idGrammar=82658417
isrc.CreateGrammar(idGrammar g)
g.LoadDictation(0 SPLO_STATIC)
g.SetDictationState(SPRS_ACTIVE)
src._setevents("sub.src")

;now wait and process messages. Can either:
;1. Show a message box or dialog.
;2. opt waitmsg 1; wait ...
;3. MessageLoop.
if 1
,mes "QM speech recognition example.[][]Say something while this message box is alive."
else
,AddTrayIcon "$qm$\sound.ico" "QM speech recognition example.[]Ctrl+click to exit."
,opt waitmsg 1
,wait -1 ;;or can wait for some event


#sub src_Recognition
function StreamNumber `StreamPosition RecognitionType SpeechLib.ISpeechRecoResult'Result ;;SpeechLib.ISpeechRecoContext'src
SpeechLib.ISpRecoResult k=+Result
word* w; byte attr
k.GetText(-1 -1 1 &w &attr)
str s.ansi(w)
CoTaskMemFree w

out s ;;the recognized word

;To start a macro, use mac. Don't put macro code here. This function must exit ASAP.
sel s 1
,case "example"
,mac "Example20"
,
,case "simple"
,mac "Simple5"

err+ out _error.description
#3
Hello,

Gintaras, I want to test this macro but I get this error message
Error in <open ":3092: /1111">Test_voice_commandConfusedrc_Recognition: unknown identifier.


Thank you
Great work
#4
Replace these SP_... with -1.
#5
Works now.

Thank you
#6
Hello
Can it be made to listen just when you keep a key pressed as opposed to having the box with Ok button?

Thanks
#7
Replace 'if 1' with 'if 0'.
Below 'function' line add:
ifk-(J 1) ret ;;do nothing if key ScrollLock is not toggled
#8
One more thing.

Can it be done with just one key press - same key to trigger the macro and to start listening in Windows Listening app and also evaluate the recognized word in quick macros - all in one go, long press. After processing, stop listening in Windows listening app stop the macro.

Thank you for taking the time.


Forum Jump:


Users browsing this thread: 3 Guest(s)