1

I'm attempting to get speech recognition for searching working for a project I'm working on. At the minute, I'm only focussing on getting the speech recognition working and I'm using pygsr to do this. I found a post about pygsr on here earlier but I'm currently struggling to get it to work. This is the code that I'm using:

from pygsr import Pygsr

speech = Pygsr()
speech.record(3)
phrase, complete_response =speech.speech_to_text('en_US')
print phrase

After spending a while installing the library with OS X, I finally got it to actually sort of work. It detected the library and worked seemingly but then I would get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 4, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pygsr/__init__.py", line 33, in record
    data = stream.read(self.chunk)
  File "/Library/Python/2.7/site-packages/pyaudio.py", line 605, in read
    return pa.read_stream(self._stream, num_frames)
IOError: [Errno Input overflowed] -9981

I have no idea if this is due to something I'm doing wrong or if I can't use pygsr on OS X. If there is no way for this to work, does anyone have any recommendations for a speech recognition library for OS X that uses Python 2.7?

Community
  • 1
  • 1
HarryMoy
  • 142
  • 3
  • 20

1 Answers1

1

you could test if it works correctly pyaudio running this script:

import pyaudio
import wave

CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
            channels=CHANNELS,
            rate=RATE,
            input=True,
            frames_per_buffer=CHUNK)

print("* recording")

frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
    frames.append(data)

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()

I received many reports that pygsr macOS is not working, but I could not fix it because I could not test it on a mac.

dr. Neox
  • 401
  • 4
  • 6