Voice triger

Creating macros. Working with QM.

Voice triger

Postby ilya1111 on Wed Oct 18, 2017 2:19 pm

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?
ilya1111
 
Posts: 23
Joined: Wed Feb 15, 2017 1:39 pm

Re: Voice triger

Postby Gintaras on Wed Oct 18, 2017 7:23 pm

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     ?
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(SP_GETWHOLEPHRASE SP_GETWHOLEPHRASE 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

Gintaras
Site Admin
 
Posts: 10385
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania


Return to General

Who is online

Users browsing this forum: No registered users and 3 guests

cron