944,144 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 8740
  • Python RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 3rd, 2007
0

Python for Laptop Robot Speech recognition and TTS.

Expand Post »
Hello Everyone. I'm new to python and so far, I simply love it! I'm still just starting to get the knack though and there's a lot more I want to know. I've decided to use it mainly for my robots' programming scripts. Right now I'm currently stuck on a simple script on getting my windows vista machine to recognize phrases I say, and reply to them using TTS. It's a learning process in itself.

Bare with me, most of the time I feel like I haven't got a clue when I'm writing a python script. It's the first programming language I'm learning.

Here's the script I'm using on my computer. I'll implement it into my robot later, once I get it to work. I modified it from two python sample scripts by Inigo Surguy and Peter Parente, so a lot of credit goes to them, at least until I become savy enough to write my original speech Recognition and TTS scripts... What I want it to do is wait for me to say "Hello, Aelita" which is what I call my laptop, and respond by addressing my name and asking how I am doing. I'm also trying to get it to tell me the time, whenever I say "Time." It is as follows:

Python Syntax (Toggle Plain Text)
  1. #Test Script for computer virtual personality.
  2. #Credits to Inigo Surguy (inigosurguy@hotmail.com) and Peter Parente for original
  3. #Speech Recognition and TTS scripts.
  4. #Further commentary by Surguy
  5. from win32com.client import constants
  6. import win32com.client
  7. import pythoncom
  8.  
  9. import pyTTS
  10. impor time
  11.  
  12. tts = pyTTS.Create()
  13.  
  14. tts.Rate = 1
  15.  
  16. tts.Volume = 90
  17.  
  18. tts.GetVoiceNames()
  19.  
  20. tts.SetVoiceByName('MS-Anna-1033-20-DSK')
  21.  
  22. """Sample code for using the Microsoft Speech SDK 5.1 via COM in Python.
  23. Requires that the SDK be installed (it's a free download from
  24. http://www.microsoft.com/speech
  25. and that MakePy has been used on it (in PythonWin,
  26. select Tools | COM MakePy Utility | Microsoft Speech Object Library 5.1).
  27.  
  28. After running this, then saying "One", "Two", "Three" or "Four" should
  29. display "You said One" etc on the console. The recognition can be a bit
  30. shaky at first until you've trained it (via the Speech entry in the Windows
  31. Control Panel."""
  32. class SpeechRecognition:
  33. """ Initialize the speech recognition with the passed in list of words """
  34. def __init__(self, wordsToAdd):
  35. # For text-to-speech
  36. self.speaker = win32com.client.Dispatch("SAPI.SpVoice")
  37. # For speech recognition - first create a listener
  38. self.listener = win32com.client.Dispatch("SAPI.SpSharedRecognizer")
  39. # Then a recognition context
  40. self.context = self.listener.CreateRecoContext()
  41. # which has an associated grammar
  42. self.grammar = self.context.CreateGrammar()
  43. # Do not allow free word recognition - only command and control
  44. # recognizing the words in the grammar only
  45. self.grammar.DictationSetState(0)
  46. # Create a new rule for the grammar, that is top level (so it begins
  47. # a recognition) and dynamic (ie we can change it at runtime)
  48. self.wordsRule = self.grammar.Rules.Add("wordsRule",
  49. constants.SRATopLevel + constants.SRADynamic, 0)
  50. # Clear the rule (not necessary first time, but if we're changing it
  51. # dynamically then it's useful)
  52. self.wordsRule.Clear()
  53. # And go through the list of words, adding each to the rule
  54. [ self.wordsRule.InitialState.AddWordTransition(None, word) for word in wordsToAdd ]
  55. # Set the wordsRule to be active
  56. self.grammar.Rules.Commit()
  57. self.grammar.CmdSetRuleState("wordsRule", 1)
  58. # Commit the changes to the grammar
  59. self.grammar.Rules.Commit()
  60. # And add an event handler that's called back when recognition occurs
  61. self.eventHandler = ContextEvents(self.context)
  62. # Announce we've started
  63. self.say("Started successfully")
  64. """Speak a word or phrase"""
  65. def say(self, phrase):
  66. self.speaker.Speak(phrase)
  67.  
  68. """The callback class that handles the events raised by the speech object.
  69. See "Automation | SpSharedRecoContext (Events)" in the MS Speech SDK
  70. online help for documentation of the other events supported. """
  71. class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):
  72. """Called when a word/phrase is successfully recognized -
  73. ie it is found in a currently open grammar with a sufficiently high
  74. confidence"""
  75. def OnRecognition(self, StreamNumber, StreamPosition, RecognitionType, Result):
  76. newResult = win32com.client.Dispatch(Result)
  77.  
  78. if __name__=='__main__':
  79. wordsToAdd = [ "Hello Aelita", "Fine", "How are you?", "Not well", "Awful",
  80. "Bad", "Not good", "Not too well", "Thank you", "Thanks", "Time" ]
  81. speechReco = SpeechRecognition(wordsToAdd)
  82. while 1:
  83. pythoncom.PumpWaitingMessages()
  84.  
  85. if speechReco("Hello Aelita"):
  86. greeting1 = "Hello, Lore-enn. How are you today?"
  87. tts.Speak(greeting1)
  88. if speechReco("Fine"):
  89. great = "Great!"
  90. tts.Speak(great)
  91. offr1 = "Is there anything I can do for you?"
  92. tts.Speak(offr1)
  93. if speechReco("Not well") or ("Awful") or ("Bad") or ("Not Good") or ("Not too well"):
  94. sorry1 = "That's too bad"
  95. sorry2 = "I'm so sorry."
  96. tts.Speak(sorry1) or (sorry2)
  97. onDuty1 = "If there's anything or need, just let me know."
  98. tts.Speak(onDuty1)
  99. if speechReco("Thanks") or ("Thank you"):
  100. hum1 = "Don't mention it"
  101. hum2 = "No problem"
  102. hum3 = "Your welcome"
  103. tts.Speak(hum1) or (hum2) or (hum3)
  104.  
  105. if speechReco("Time"):
  106. timeStr1 = "The time is " + time.asctime(),
  107. timeStr2 = "It's " + time.asctime()
  108. timeStr3 = "Right now, it's " + time.asctime()
  109. tts.Speak(timeStr1) or (timeStr2) or (timeStr3)

It's working mostly, in that it opens up Microsoft Speech Recognition and recognizes the words I say, and as far as I know the script is free from syntax errors and exceptions. The problem I'm having now is getting the computer's voice to say something back. As of now, the phrase just shows up in the MSR window but doesn't say anything back. I think it has to do with the "speechReco" I write for when the computer's supposed to catch a certain phrase. I don't think its the right term. So, the MSR is recognizing my words, but the python script doesn't, hence no TTS response. I'd appreciate it if maybe someone could help me out with this script, and/or tell me if there's some sort of python syntax dictionary or glossary out there, that tells all the different words you can right in a python script, when to use them, and what they do?

Once again, bare with me. I'm trying to learn as much as I can about this stuff. Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Seagull One is offline Offline
61 posts
since Aug 2007
Sep 3rd, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

It's good code, seagull (or should I say "Lore-enn"?). You're asking a question that has more to do with the speech recognition module than Python, so I can't directly help. But when I'm stuck on such, I usually try out the help files.

In this case, it looks as if tts.Speak() isn't working like you'd want. So from the command line:

Python Syntax (Toggle Plain Text)
  1. import pyTTS
  2.  
  3. tts = pyTTS.Create()
  4. help(tts.Speak)

and see if you get anything useful.

BTW, there is a typo in the line "impor time" --> should be "import time". I don't think that'll fix the code, though.

Hope it helps,
Jeff
Reputation Points: 92
Solved Threads: 156
Practically a Master Poster
jrcagle is offline Offline
608 posts
since Jul 2006
Sep 3rd, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

Thanks for the input, jrcagle. Name's actually Loren, but wanted the TTS to pronounce it right.

The script still doesn't seem to be working. I'm not sure its the pyTTS that's not working but it always working fine in the interactive window...But even surguy's original speech recognition script didn't work completely when I downloaded it directly and tried it. The Microsoft Speech Recognition for Vista window still opened up and recognized the phrases I said, but I got no response. In surguy's script, the computer was supposed to print on the screen "You said ", and it would be "One," "Two," "Three," or "Four," depending on which of the four numbers you said. But all that came up in my Microsoft Speech Recognition was "One" "Two" "Three" or "Four." and it does that anyway, even without the python script. No window came up or anything that said, "You said one," or "You said two." I wonder if it has anything to do with Microsoft Speech Recognition which opens every time I run the script. Maybe its interferring somehow, because I don't think Surguy intended his script to work with Microsoft Speech Recognition on a windows Vista machine...

Does anyone know what would happen if I tried it on a different O.S. What if I ran the script in a windows XP or 98 on Microsoft Virtual PC? I think that's what I'll try and see what happens...
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Seagull One is offline Offline
61 posts
since Aug 2007
Sep 5th, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

Okay, here's the code after I cleaned it up a bit. The computer's TTS still isn't giving any output whenever I say a phrase, like "Hello Aelita."
Python Syntax (Toggle Plain Text)
  1. #Test Script for computer virtual personality.
  2. #Credits to Inigo Surguy (inigosurguy@hotmail.com) and Peter Parente for original
  3. #Speech Recognition and TTS scripts.
  4. #Further commentary by Surguy
  5. from win32com.client import constants
  6. import win32com.client
  7. import pythoncom
  8.  
  9. import time
  10.  
  11. """Sample code for using the Microsoft Speech SDK 5.1 via COM in Python.
  12. Requires that the SDK be installed (it's a free download from
  13. http://www.microsoft.com/speech
  14. and that MakePy has been used on it (in PythonWin,
  15. select Tools | COM MakePy Utility | Microsoft Speech Object Library 5.1).
  16.  
  17. After running this, then saying "One", "Two", "Three" or "Four" should
  18. display "You said One" etc on the console. The recognition can be a bit
  19. shaky at first until you've trained it (via the Speech entry in the Windows
  20. Control Panel."""
  21. class SpeechRecognition:
  22. """ Initialize the speech recognition with the passed in list of words """
  23. def __init__(self, wordsToAdd):
  24. # For text-to-speech
  25. self.speaker = win32com.client.Dispatch("SAPI.SpVoice")
  26. # For speech recognition - first create a listener
  27. self.listener = win32com.client.Dispatch("SAPI.SpSharedRecognizer")
  28. # Then a recognition context
  29. self.context = self.listener.CreateRecoContext()
  30. # which has an associated grammar
  31. self.grammar = self.context.CreateGrammar()
  32. # Do not allow free word recognition - only command and control
  33. # recognizing the words in the grammar only
  34. self.grammar.DictationSetState(0)
  35. # Create a new rule for the grammar, that is top level (so it begins
  36. # a recognition) and dynamic (ie we can change it at runtime)
  37. self.wordsRule = self.grammar.Rules.Add("wordsRule",
  38. constants.SRATopLevel + constants.SRADynamic, 0)
  39. # Clear the rule (not necessary first time, but if we're changing it
  40. # dynamically then it's useful)
  41. self.wordsRule.Clear()
  42. # And go through the list of words, adding each to the rule
  43. [ self.wordsRule.InitialState.AddWordTransition(None, word) for word in wordsToAdd ]
  44. # Set the wordsRule to be active
  45. self.grammar.Rules.Commit()
  46. self.grammar.CmdSetRuleState("wordsRule", 1)
  47. # Commit the changes to the grammar
  48. self.grammar.Rules.Commit()
  49. # And add an event handler that's called back when recognition occurs
  50. self.eventHandler = ContextEvents(self.context)
  51. # Announce we've started
  52. self.say("Started successfully")
  53. """Speak a word or phrase"""
  54. def say(self, phrase):
  55. self.speaker.Speak(phrase)
  56.  
  57. """The callback class that handles the events raised by the speech object.
  58. See "Automation | SpSharedRecoContext (Events)" in the MS Speech SDK
  59. online help for documentation of the other events supported. """
  60. class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):
  61. """Called when a word/phrase is successfully recognized -
  62. ie it is found in a currently open grammar with a sufficiently high
  63. confidence"""
  64. def OnRecognition(self, StreamNumber, StreamPosition, RecognitionType, Result):
  65. newResult = win32com.client.Dispatch(Result)
  66.  
  67. if __name__=='__main__':
  68. wordsToAdd = [ "Hello Aelita", "Fine", "Good", "Great", "Wonderful", "How are you?",
  69. "Not well", "Awful", "Bad", "Not good", "Not too well", "Thank you", "Thanks", "Time" ]
  70. speechReco = SpeechRecognition(wordsToAdd)
  71. while 1:
  72. pythoncom.PumpWaitingMessages()
  73.  
  74. if RecognitionType == ("Hello Aelita"):
  75. self.say("Hello, Loren. How are you today?")
  76. if RecognitionType == ("Fine") or ("Great") or ("Wonderful") or ("Good"):
  77. say("Great")
  78. say("Is there anything I can do for you?")
  79. if RecognitionType == ("Not well") or ("Awful") or ("Bad") or ("Not Good") or ("Not too well"):
  80. say("That's too bad")
  81. say("If there's anything or need, just let me know.")
  82.  
  83. if RecognitionType == ("Time"):
  84. say("The time is " + time.asctime(),)
The words come up on MSR, so I know it recognized what I said, but there still no speech, other than "Started Sucesfully" at the beginning when I first run the script. After that, my computer's completely silent. I'm still skeptical that I'm using the right syntax for when the computer's supposed to recognize my phrase and say something. Right now I'm typing "if RecognitionType == ("Hello Aelita")" and I don't think 'RecognitionType' is the right command word for it. Does this script work on anyone elses PC?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Seagull One is offline Offline
61 posts
since Aug 2007
Sep 7th, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

I'm completely out of my waters -- I've never even used Vista (waiting for SP 2 to work out the bugs...).

That said, this looks iffy to me:

Python Syntax (Toggle Plain Text)
  1. if RecognitionType == ("Hello Aelita"):
  2. self.say("Hello, Loren. How are you today?")
  3. if RecognitionType == ("Fine") or ("Great") or ("Wonderful") or ("Good"):
  4. say("Great")
  5. say("Is there anything I can do for you?")
  6. if RecognitionType == ("Not well") or ("Awful") or ("Bad") or ("Not Good") or ("Not too well"):
  7. say("That's too bad")
  8. say("If there's anything or need, just let me know.")
  9.  
  10. if RecognitionType == ("Time"):
  11.  
  12.  
  13. say("The time is " + time.asctime(),)

Shouldn't it be 'self.say' for all of those?

Jeff
Reputation Points: 92
Solved Threads: 156
Practically a Master Poster
jrcagle is offline Offline
608 posts
since Jul 2006
Sep 7th, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

Your right, I guess it should've been self.say.
But anyhow, I've downloaded a more useful python desktop Speech Recognition code that I seemed to have neglected on the same website from Inigo Surguy. It not only has a more useful python script, but part of the code allows you to edit your own commands and macros into the speech recognition database.

Now here's an interesting discovery I've made. I added "Hello Aelita" to the list of recognizeable words with the command "tts.Speak('Hello, Loren. How are you today?")" in the actions window, or whatever you call it. Now, when I click on the Test button to see if it works, I get the computer's voice "Hello, Loren. How are you toady." But whenever I speak "Hello Aelita" the computer still recognizes the words, but there's no voice? Which is very interesting.

I think I'll download python and the necessary requirements to run the script onto my XP desktop computer and see if I get better results.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Seagull One is offline Offline
61 posts
since Aug 2007
Sep 7th, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

Jrcagle, I think you're right about the TTS module not working like I want it to. Apparently, anytime I type in: tts.Speak("Blah, blah, blah"), in the interactive window, I get a response. The speakers will play a TTS Voice that says, "Blah, blah, blah." But whenever I add it to the speech recognition list of words to recognize and speak "Hello Aelita" into the microphone, nothing. It plays the voice when I click Test, so in Theory it should be working perfectly. But I never get anything when I speak into the microphone.

But check this out. I added google to the list of words to be recognized. I then added "browseTo("www.google.com")" to the actions window. when I spoke "google" into the microphone, wahlah! It went to google just like I wanted it to. So I know its not my vista computer. At least, I think.

So I typed in "help(tts.Speak)", like you told me to, jrcagle. I got a reply, but its half greek to me. I got this:
Python Syntax (Toggle Plain Text)
  1. Help on method Speak in module pyTTS.sapi:
  2.  
  3. Speak(self, text, *flags) method of pyTTS.sapi.SynthAndOutput instance
  4. Speaks text with the optional flag modifiers. Text can include XML commands.

I'm still a python newbie: a get a very rough idea of what it means, but I'm still not at a level where I can take that information and find out how to make my computer talk to me like it should. If this is more of a speech recognition to TTS issue rather than python, does anyone know where I can go to learn how to fix this?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Seagull One is offline Offline
61 posts
since Aug 2007
Sep 9th, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

Yipee! I got it to work!

Here's what I did. I not only loaded the direct speech object in makepython, but I also applied the direct speech recognition. Also, I had to make sure that I had the interactive window selected, otherwise, nothing would happen.

Thanks for your help. Now to move on with my robot!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Seagull One is offline Offline
61 posts
since Aug 2007
Sep 9th, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

Great debugging job!
Reputation Points: 92
Solved Threads: 156
Practically a Master Poster
jrcagle is offline Offline
608 posts
since Jul 2006
Sep 16th, 2007
0

Re: Python for Laptop Robot Speech recognition and TTS.

Sorry, long post.

Okay, it's been a while since I've tested the code on my laptop computer. Since the actual
construction on my autonomous robot is to begin very soon, I've been experimenting with the actual code that's going to go into the robot.

I know there's something wrong with my code because it keeps raising an exception:
Python Syntax (Toggle Plain Text)
  1. Traceback (most recent call last):
  2. File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 305, in RunScript
  3. debugger.run(codeObject, __main__.__dict__, start_stepping=1)
  4. File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run
  5. _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  6. File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 631, in run
  7. exec cmd in globals, locals
  8. File "C:\Users\Owner\Desktop\Nina Interaction.py", line 109, in <module>
  9. "What time is it" : "speaker.Speak('The time is ' + time.asctime)"}
  10. NameError: name 'self' is not defined

Which is puzzling because isn't (self) supposed to be a natural, integrated part of the python programming language?

Here is my code. Once again, I make use of Inigo Surguy's speech recognition sample code, and some sample code from Christian Wyglendowski's timer scripts.

Python Syntax (Toggle Plain Text)
  1. # A code to Interact with an autonomous robot called Nina.
  2. # Modified from Inigo Surguy's sample code for speech recognition
  3. # and the timer sample scripts by Christian Wyglendowski (http://mail.python.org/pipermail/tutor/2004-November/033333.html)
  4. # Further commentary by Surguy.
  5.  
  6. # Sample code for speech recognition using the MS Speech API
  7. # Inigo Surguy (inigosurguy@hotmail.com)
  8. import time
  9. import threading
  10. class Timer(threading.Thread):
  11. def __init__(self, seconds):
  12. self.runTime = seconds
  13. threading.Thread.__init__(self)
  14. def run(self):
  15. time.sleep(self.runTime)
  16.  
  17. class GreetingTimer(Timer):
  18. def run(self):
  19. counter = self.runTime
  20. for sec in range(self.runTime):
  21. time.sleep(1.0)
  22. counter -= 1
  23. Greeting = 0
  24.  
  25. GT = GreetingTimer(10)
  26.  
  27. Greeting = 0
  28.  
  29. from win32com.client import constants
  30. import win32com.client
  31. import pythoncom
  32.  
  33. """Sample code for using the Microsoft Speech SDK 5.1 via COM in Python.
  34. Requires that the SDK be installed (it's a free download from
  35. http://www.microsoft.com/speech
  36. and that MakePy has been used on it (in PythonWin,
  37. select Tools | COM MakePy Utility | Microsoft Speech Object Library 5.1).
  38.  
  39. After running this, then saying "One", "Two", "Three" or "Four" should
  40. display "You said One" etc on the console. The recognition can be a bit
  41. shaky at first until you've trained it (via the Speech entry in the Windows
  42. Control Panel."""
  43. class SpeechRecognition:
  44. """ Initialize the speech recognition with the passed in list of words """
  45. def __init__(self, wordsToAdd):
  46. # For text-to-speech
  47. self.speaker = win32com.client.Dispatch("SAPI.SpVoice")
  48. # For speech recognition - first create a listener
  49. self.listener = win32com.client.Dispatch("SAPI.SpSharedRecognizer")
  50. # Then a recognition context
  51. self.context = self.listener.CreateRecoContext()
  52. # which has an associated grammar
  53. self.grammar = self.context.CreateGrammar()
  54. # Do not allow free word recognition - only command and control
  55. # recognizing the words in the grammar only
  56. self.grammar.DictationSetState(0)
  57. # Create a new rule for the grammar, that is top level (so it begins
  58. # a recognition) and dynamic (ie we can change it at runtime)
  59. self.wordsRule = self.grammar.Rules.Add("wordsRule",
  60. constants.SRATopLevel + constants.SRADynamic, 0)
  61. # Clear the rule (not necessary first time, but if we're changing it
  62. # dynamically then it's useful)
  63. self.wordsRule.Clear()
  64. # And go through the list of words, adding each to the rule
  65. [ self.wordsRule.InitialState.AddWordTransition(None, word) for word in wordsToAdd ]
  66. # Set the wordsRule to be active
  67. self.grammar.Rules.Commit()
  68. self.grammar.CmdSetRuleState("wordsRule", 1)
  69. # Commit the changes to the grammar
  70. self.grammar.Rules.Commit()
  71. # And add an event handler that's called back when recognition occurs
  72. self.eventHandler = ContextEvents(self.context)
  73. # Announce we've started
  74. self.say("Started Successfully")
  75. """Speak a word or phrase"""
  76. def say(self, phrase):
  77. self.speaker.Speak(phrase)
  78.  
  79. """The callback class that handles the events raised by the speech object.
  80. See "Automation | SpSharedRecoContext (Events)" in the MS Speech SDK
  81. online help for documentation of the other events supported. """
  82. class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):
  83. """Called when a word/phrase is successfully recognized -
  84. ie it is found in a currently open grammar with a sufficiently high
  85. confidence"""
  86. def OnRecognition(self, StreamNumber, StreamPosition, RecognitionType, Result):
  87. newResult = win32com.client.Dispatch(Result)
  88.  
  89. def SetItems(self):
  90. self.items = pickle.load(open(self.SAVE_FILENAME))
  91.  
  92.  
  93. while Greeting == 1:
  94. self.items = {"Fine" : "self.say('That's good to hear!'); Greeting = 0",
  95. "Great" : "self.say('Fantasic!'); Greeting = 0",
  96. "Wonderful" : "self.say('That's spectacular'); Greeting = 0",
  97. "Not Good" : "self.say('That's too bad'); Greeting = 0",
  98. "Terrible" : "speaker.Speak('I'm sorry'); Greeting = 0",
  99. "Awful" : "speaker.Speak('Oh I'm very sorry'); Greeting = 0"}
  100.  
  101.  
  102. if __name__=='__main__':
  103. wordsToAdd = [ "Hello Nina", "Fine", "Great", "Wonderful", "Not Good", "Terrible", "Awful",
  104. "What time is it"]
  105. speechReco = SpeechRecognition(wordsToAdd)
  106. while 1:
  107. pythoncom.PumpWaitingMessages()
  108. self.items = {"Hello Nina" : "Greeting = 1; GT.start",
  109. "What time is it" : "speaker.Speak('The time is ' + time.asctime)"}

Here's how it's supposed to work:

My robot, Nina, understands serveral words in a human-interaction vocabulary (wordsToAdd). While Nina is waiting for things to be said to her (pythoncom.PumpWaitingMessages), there are two things that are availiable to say: Hello Nina, and What time is it. When you say "Hello Nina" Nina responds by saying hello and asking how you're doing. From that point on, you can only say six responses for how you're doing, 3 positive and 3 negative.

Timing is supposed to be an important part of Nina's interaction with Humans. When you say, hello Nina, and the Greeting stance is on, Nina waits ten seconds for you to respond, otherwise she "gets bored" and assumes she's not talking to anyone anymore, to put it in personified terms...

First off, anyone know how to fix that bizzare exception? Secondly, while I'm working at it, anyone have any pointers to polish up this script? I'd greatly appreciat any help.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Seagull One is offline Offline
61 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: pygame: click and picture appears
Next Thread in Python Forum Timeline: Pygame + Python Keyboard Input Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC