Closed shreshthagarg21 closed 7 years ago
Following is my code: Trying to run it, its giving output but wrong one. It's not recognizing correct audio. but it works fine for google speech api .
import speech_recognition as sr import pyttsx
speech_engine = pyttsx.init() speech_engine.setProperty('rate', 150)
def speak(text): speech_engine.say(text) speech_engine.runAndWait()
def listen():
r = sr.Recognizer() with sr.Microphone() as source: #print("Say something!") audio = r.listen(source) try: print("You said: " + r.recognize_sphinx(audio)) except sr.UnknownValueError: print("Could not understand audio") except sr.RequestError as e: print("Error; {0}".format(e))
speak("Say something!") listen()
Example audio: hello Expected output : hello Actual output: (Random like ken bode) Errors:
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib setup.c:548:(add_elem) Cannot obtain info for CTL elem (MIXER,'IEC958 Playback Default',0,0,0): No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
System: Ubuntu 14.04 Python 2.7 Pip 1.5.4 pyttsx 1.1 SpeechRecognition 3.6.5 Pyaudio 0.2.11 PocketSphinx from given linux commands Please suggest how to proceed further. Not getting the errors how can i bring the correct output.
Thanks
Hi @shreshthagarg21,
This is expected behaviour, as the Sphinx model is trained on far less data than the likes of those from Google.
Following is my code: Trying to run it, its giving output but wrong one. It's not recognizing correct audio. but it works fine for google speech api .
import speech_recognition as sr import pyttsx
speech_engine = pyttsx.init() speech_engine.setProperty('rate', 150)
def speak(text): speech_engine.say(text) speech_engine.runAndWait()
def listen():
Record Audio
speak("Say something!") listen()
Example audio: hello Expected output : hello Actual output: (Random like ken bode) Errors:
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib setup.c:548:(add_elem) Cannot obtain info for CTL elem (MIXER,'IEC958 Playback Default',0,0,0): No such file or directory ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
System: Ubuntu 14.04 Python 2.7 Pip 1.5.4 pyttsx 1.1 SpeechRecognition 3.6.5 Pyaudio 0.2.11 PocketSphinx from given linux commands Please suggest how to proceed further. Not getting the errors how can i bring the correct output.
Thanks