Jump to content

Simplified SAPI Speech Recogniton


ConsultingJoe
 Share

Recommended Posts

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

so did your script stop listening at all while testing it

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

actually, yes...it only works the first time, then it doesn't recognize anything after that

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

actually, yes...it only works the first time, then it doesn't recognize anything after that

well mine works a little longer usually but i dont know much about objects and the SR, is there anyone that can help

p.s. what do you think of my site

Edited by zerocool60544

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

very simple fix...

$Grammar.DictationSetState($SGDSActive);CONTINUE LISTENING

just put that at the end of the listening loop...

while 1
Sleep(100)
if $recog <> "" Then
Select
Case $recog = "exit"
exit;HEAR EXIT
Case $recog = "hello"
MsgBox(0,"hi","HI",1);HEAR HELLO
Case $recog = "I love you"
MsgBox(0,"","I love you too",1)
Case $recog = "test"
MsgBox(0,"","What are you testing LOSER",1)
EndSelect
;_talkOBJ($recog, 3); TALKS AFTER IT HEARS SOMETHING, The mic hears the pc and affects the recognition
_talkOBJ($recog, 3, "dont talk"); JUST POP-UP
Endif
$recog = "";SET TO NULL FOR REPEATED COMMANDS
$Grammar.DictationSetState($SGDSActive);CONTINUE LISTENING
WEnd

like that. It worked for me.

:o

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

POST the complete script you did because it looks like moved things around

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

no not really...

Global $recog = "PLEASE SPEAK NOW";SET GLOBAL
$RecoContext=ObjCreate("SAPI.SpSharedRecoContext")
if @error then
Msgbox(0,"","Error opening $RecoContext: " & @error);ERROR CHECK
exit
endif
$SinkObject=ObjEvent($RecoContext,"MYEvent_")
$SPRS_INACTIVE = 0
$SPRS_ACTIVE = 1
$SGDSActive=$SPRS_ACTIVE
$SGDSInactive=$SPRS_INACTIVE

$Grammar = $RecoContext.CreateGrammar(1)
$Grammar.Dictationload
$Grammar.DictationSetState($SGDSActive);LISTEN
while 1
Sleep(100)
if $recog <> "" Then
Select
Case $recog = "exit"
exit;HEAR EXIT
Case $recog = "hello"
MsgBox(0,"hi","HI",1);HEAR HELLO
Case $recog = "I love you"
MsgBox(0,"","I love you too",1)
Case $recog = "test"
MsgBox(0,"","What are you testing LOSER",1)
EndSelect
;_talkOBJ($recog, 3); TALKS AFTER IT HEARS SOMETHING, The mic hears the pc and affects the recognition
_talkOBJ($recog, 3, "dont talk"); JUST POP-UP
Endif
$recog = "";SET TO NULL FOR REPEATED COMMANDS
$Grammar.DictationSetState($SGDSActive);CONTINUE LISTENING
WEnd
;$Grammar.DictationSetState($SGDSInactive);STOP LITENING


Func MYEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result)
$recog = $Result.PhraseInfo.GetText;SET $recog VAR
EndFunc
Func _TalkOBJ($s_text, $s_voice = 3, $s_dont = "")
Local $quite = 0
Local $o_speech = ObjCreate ("SAPI.SpVoice")
Select
Case $s_voice == 1
$o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0)
TrayTip("Female Reader",$s_text,1)
Case $s_voice == 2
$o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0)
TrayTip("Male Reader",$s_text,1)
Case $s_voice == 3
$o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0)
TrayTip("OldMan Reader",$s_text,1)
EndSelect
if $s_dont <> "dont talk" then
$o_speech.Speak ($s_text)
$o_speech = ""
ENDif
Sleep(1000)
TrayTip("","",1)
EndFunc;==>_TalkOBJ
Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

made a bunch of changes...

Global $recog = "PLEASE SPEAK NOW";SET GLOBAL
$RecoContext=ObjCreate("SAPI.SpSharedRecoContext")
if @error then
Msgbox(0,"","Error opening $RecoContext: " & @error);ERROR CHECK
exit
endif
$SinkObject=ObjEvent($RecoContext,"MYEvent_")
$SPRS_INACTIVE = 0
$SPRS_ACTIVE = 1
$SGDSActive=$SPRS_ACTIVE
$SGDSInactive=$SPRS_INACTIVE
$voice = 3
$silent = ""

$Grammar = $RecoContext.CreateGrammar(1)
$Grammar.Dictationload
$Grammar.DictationSetState($SGDSActive);LISTEN
while 1
Sleep(100)
If $recog <> "" Then
If $recog = "exit" Then
    Exit
ElseIf $recog = "PLEASE SPEAK NOW" Then
    _TalkOBJ("PLEASE SPEAK NOW")
ElseIf $recog = "Set Voice Mary" Then
    $voice = 1
    _TalkOBJ ("Mary here", 1, $silent)
ElseIf $recog = "Set Voice Mike" Then
    $voice = 2
    _TalkOBJ ("Mike, reporting for duty", 2, $silent)
ElseIf $recog = "Set Voice Sam" Then
    $voice = 3
    _TalkOBJ ("You have selected Sam", 3, $silent)
ElseIf $recog = "Silence" Then
    $silent = "dont talk"
    _TalkOBJ("Shhhh!", $voice, "dont talk")
ElseIf $recog = "Speak" Then
    $silent = ""
    _TalkOBJ("I'm here to talk", $voice, $silent)
Else
    _TalkOBJ(SR_reply($recog), $voice, $silent)
EndIf
EndIf
$recog = "";SET TO NULL FOR REPEATED COMMANDS
$Grammar.DictationSetState($SGDSActive);CONTINUE LISTENING
WEnd
;$Grammar.DictationSetState($SGDSInactive);STOP LITENING


Func MYEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result)
$recog = $Result.PhraseInfo.GetText;SET $recog VAR
EndFunc
Func _TalkOBJ($s_text, $s_voice = 3, $s_dont = "")
Local $quite = 0
Local $o_speech = ObjCreate ("SAPI.SpVoice")
Select
Case $s_voice == 1
$o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0)
TrayTip("Female Reader",$s_text,1)
Case $s_voice == 2
$o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0)
TrayTip("Male Reader",$s_text,1)
Case $s_voice == 3
$o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0)
TrayTip("OldMan Reader",$s_text,1)
EndSelect
if $s_dont <> "dont talk" then
$o_speech.Speak ($s_text)
$o_speech = ""
ENDif
Sleep(1000)
TrayTip("","",1)
EndFunc;==>_TalkOBJ

Func SR_reply($text)
    Switch $text
        Case "hi"
            Return "hello"
        Case "hello"
            Return "Hi there!"
        Case "test"
            Return "What the heck are you testing?"
    EndSwitch
    Return "I'm Sorry. I did not understand what you said. Please try again."
EndFunc

everything works fine, but after awhile, SCiTE will tell me that the script stopped responding...

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

I worked a little. Nice setup but it still has the same problem

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

yeah, lets see if we can get this thing figured out...

what I find interesting is that it not only stops listening, but the process itself completely stops responding.

By the Way.....I got my AIML bot to work with this, but still same problem.

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

yeah, lets see if we can get this thing figured out...

what I find interesting is that it not only stops listening, but the process itself completely stops responding.

By the Way.....I got my AIML bot to work with this, but still same problem.

yeah, I think that it has to do with the grammar, it probably thinks your not done talking or something. i am clueless, why does it have to be so hard??

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

where did you find the information about the SR? Somewhere on MSDN maybe?

http://www.autoitscript.com/forum/index.ph...c=14106&hl=sapi

or

http://www.autoitscript.com/forum/index.ph...c=13974&hl=sapi

Edited by zerocool60544

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

hmm ok I will research MSDN some then.

I tryied but I really dont know any VB or C++

Thanks.

This could be used in almost every script.

I can't wait to have a convo with my computer

lol I'm a loser :o

Edited by zerocool60544

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

I tryied but I really dont know any VB or C++

Thanks.

This could be used in almost every script.

I can't wait to have a convo with my computer

lol I'm a loser :o

lol

Man this is harder than I thought...

All I need is some good documentation on SAPI.SpSharedRecoContext...

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

lol

Man this is harder than I thought...

All I need is some good documentation on SAPI.SpSharedRecoContext...

Check this out:

http://msdn.microsoft.com/library/default....RecoContext.asp

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

now, that was useful! I looked through and found that $RecoContext.CreateGrammar creates a new object. And, Dictationload isn't there, but rather LoadDictation... also, SetDictationState is in there instead of DictationSetState...I'm going to experiment with this info a little...

man...I changed those to what msdn said (which obviously should be official) and it just stopped working. I get "The requested action with this object has failed.". So obviously that wasn't right. :o

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

I made one of these last year, and I had it recognizing basic commands like "my computer" or "volume up". However, I stopped when i hit the following problem: the word "winamp". or indeed, any word not in the speech library. I dont know how to add words to the recognition library! The speech thing had NO IDEA what "winamp" was, so it always translated it to something different each time, so i could never do something simple like "run winamp". I still have the code laying around if anybody is interested. I would really like to get this sort of thing working.

Perhaps we could make some sort of context sensitive system where the commands are based on the current context. Perhaps people could make their own script. For example, my "winamp.au3" script would be included (pretending i made one). If you had somebody elses "winamp.au3", the commands would be different, so the whole thign would sort of be personalizable. By context sensitive I mean that the commands are based on what you are currently doing or just did. For example, If i say "raise the volume" and I'm in windows media player, it raises the volume in there. If i said "raise the volume" and I'm in winamp, it searches the "winamp.au3" for what to do when it wants to raise the volume, and then it follows those specific commands. This way soembody could create individual sections for different programs, like for games and such.

*shrug*

Link to comment
Share on other sites

WOW That would be great if we could get the code, I am so confused as to why this script stops listening, I've been trying things for weeks now. And great idea about the context. I wanted to make two scripts one that people can create commands that listen for words then the script would do what is setup like run a program or send keys or play music. The second script would be an AI TTS SR script with custom brain files.

So yeah just post your script

Thanks a lot

Zerocool

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...