jbest / pyspeech

Automatically exported from code.google.com/p/pyspeech
0 stars 0 forks source link

recursive listening #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.

i'm using the script
import speech

def response(phrase, listener):
    speech.say("You said %s" % phrase)
    if phrase == "turn off":
        listener.stoplistening()

listener = speech.listenfor(
    ['Sleepy', 'Happy', 'Dopey', 'Killer', 'Sneezy', 'Bashful', 'Doc',
'turn off'],
    response)

# Your program can do whatever it wants now, and when a dwarf's name is heard,
# response() will be called on a separate thread.  This can happen over and
over --
# as long as the listener hasn't been stopped.
import time
while listener.islistening():
    time.sleep(1)
    print "Still waiting..."

the problem is after 20 times recognition, the system seems to pick the
sound of what they say. so it makes a recursive speech. (the system listen
for what he says)

suggestion: make a pause listening while the system is still saying something.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
windows XP . python 2.4

Please provide any additional information below.

Original issue reported on code.google.com by irz...@gmail.com on 19 Sep 2008 at 3:46

GoogleCodeExporter commented 9 years ago
izraip, I am *so* sorry that I didn't follow up on this.  I managed to lose the 
email
bug report and just now noticed it.

I don't feel that pausing listening in the speech library is the appropriate 
way to
handle this.  If you want to speak while the computer is speaking, it would be a
frustrating user experience for it to be invisibly holding its ears.  You might 
be
piping speech output to headphones in which case this isn't a problem, or you 
might
be using a synthesized voice that doesn't match your own, which wouldn't cause 
the
problem.

I had this problem myself when developing http://musicbutler.googlecode.com, 
and have
a few suggestions:

  * Use a female voice if you're a male and vice versa.  This will make Windows less
likely to falsely recognize your voice.

  * Listen for phrases that start with a keyword.  All my musicbutler commands start
with saying the name of the butler, such as "Einstein, play me some Beach 
Boys." 
This makes it unlikely that the computer's voice, or music played over the 
stereo,
will match a phrase being listened for.

  * Manually stop listening before speech.say, and then listen again.  I don't have a
way to programmatically pause listening in the speech API at the moment, so 
your only
option would be to listener.stoplistening() and then to restart.  You could 
wrap the
starting of the listener in a helper function so that you don't duplicate code;
something like

    mylistener = null
    def startup():
        global mylistener
        mylistener = speech.listenfor(["Foo", "Bar", "Baz"], response)
    def response(phrase, listener):
        listener.stoplistening()
        speech.say("Nothing is listening right now")
        startup()
    startup()
    # at the end of the program, you turn off listening via...
    mylistener.stoplistening()

Original comment by gundl...@gmail.com on 21 Oct 2008 at 11:23