[Tutor] Having trouble figuring out bug

Steven D'Aprano steve at pearwood.info
Thu Feb 14 01:51:43 CET 2013


On 14/02/13 11:16, richard kappler wrote:
> On Wed, Feb 13, 2013 at 6:56 PM, Steven D'Aprano<steve at pearwood.info>wrote:
>
>> On 14/02/13 10:14, richard kappler wrote:
>>
>>> I have tried to run the Google speech recognition code found here:
>>> https://github.com/jeysonmc/**python-google-speech-scripts/**
>>> blob/master/stt_google.py<https://github.com/jeysonmc/python-google-speech-scripts/blob/master/stt_google.py>
>>>
>>> I am getting the following traceback:
>>> Traceback (most recent call last):
>>>     File "<stdin>", line 1, in<module>
>>>     File "GoogSTT.py", line 43, in listen_for_speech
>>>       data = stream.read(chunk)
>>>     File "/usr/lib/python2.7/dist-**packages/pyaudio.py", line 605, in
>>> read
>>>       return pa.read_stream(self._stream, num_frames)
>>>
>>
>>
>> Awesome!
>>
>> Richard, if you hang around this mailing list for a while, you will soon
>> see that we tutors have a lot of trouble convincing newbies to post the
>> entire traceback, not just the error message. But this is the first time
>> that somebody has posted the traceback EXCEPT for the error message.
>>
>> Well done, you win the Internet :-)
>>
>> Please try again and post the entire traceback, including the error
>> message at the end.
>>
>> Thank you.
>>
>>
>> And now you see my dilemma. That's the error message, the whole bloody
> thing. But for ye unbelievers out there, here's my entire screen, from the
> call to the crash:
>
> python GoogSTT.py
> ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
> ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
> ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect)
> BT_GET_CAPABILITIES failed : Input/output error(5)
> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect)
> BT_GET_CAPABILITIES failed : Input/output error(5)
> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect)
> BT_GET_CAPABILITIES failed : Input/output error(5)
> ALSA lib audio/pcm_bluetooth.c:1614:(audioservice_expect)
> BT_GET_CAPABILITIES failed : Input/output error(5)
> ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only
> playback stream
> Cannot connect to server socket err = No such file or directory
> Cannot connect to server request channel
> jack server is not running or cannot be started
> * listening. CTRL+C to finish.
> starting record
> ^CTraceback (most recent call last):
>    File "GoogSTT.py", line 108, in<module>
>      listen_for_speech()
>    File "GoogSTT.py", line 43, in listen_for_speech
>      data = stream.read(chunk)
>    File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 605, in read
>      return pa.read_stream(self._stream, num_frames)
> KeyboardInterrupt

See that KeyboardInterrupt line? That was missing from your first post.

You get that because you have hit Ctrl-C, which is Python's way of halting the running code (if possible). If you don't want this exception, then don't hit Ctrl-C.

Which of course brings you to a dilemma -- the software tells you to use Ctrl-C to stop recording, but it apparently lies. I suggest that it is buggy. Looking at the source code to the library, here:

https://github.com/jeysonmc/python-google-speech-scripts/blob/master/stt_google.py

I'm pretty sure it is buggy. There is no attempt to catch the Ctrl-C and continue processing. I could be wrong, because I haven't actually tested it or studied it in detail, but I can't see how this could possibly work as advertised.

Also the library includes something which gives me the absolute heebie-jeebies: it downloads a website from the Internet, then *executes it as code* without making any attempt to see what it is. If you run this library, you are giving Google, or anyone that manages to intercept your connection to Google, carte blanche to run ANY CODE THEY LIKE on your computer. I wouldn't touch that library with a fifty-foot pole until that is fixed.




-- 
Steven


More information about the Tutor mailing list