Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

RuntimeError: new_Decoder returned -1 #42

Open
vipulsurya opened this issue Feb 14, 2019 · 2 comments
Open

RuntimeError: new_Decoder returned -1 #42

vipulsurya opened this issue Feb 14, 2019 · 2 comments

Comments

@vipulsurya
Copy link

vipulsurya commented Feb 14, 2019

hi
i want speech recognition using sphinx but as the accuracy of sphinx is not good at all. so need to decode the wav file but getting some error into the file....can any one please help me on this.
please tell me any alternate way to achieve offline speech recognition...

from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
import speech_recognition as sr
from os import environ,path
from itertools import izip
from pocketsphinx import *
from sphinxbase import *

MODELDIR = "C:/ProgramData/Anaconda2/Lib/site-packages/pocketsphinx/model/"
DATADIR = "C:/ProgramData/Anaconda2/Lib/site-packages/pocketsphinx/data/"

AUDIO_FILE = path.join(path.dirname(path.realpath(file)), "seriously.wav")

r = sr.Recognizer()

config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'hmm/en_US/hub4wsj_sc_8k'))
config.set_string('-lm', path.join(MODELDIR, 'lm/en_US/hub4.5000.DMP'))
config.set_string('-dict', path.join(MODELDIR, 'lm/en_US/hub4.5000.dic'))

decoder = Decoder(config)

decoder = decoder.decode_raw(open(AUDIO_FILE, 'rb'))

hypothesis = decoder.hyp()

for best, i in izip(decoder.nbest(), range(10)):
print best.hyp().best_score, best.hyp().hypstr

decoder = Decoder(config)

#decoder.start_utt('goforward')
decoder.start_utt()
stream = open(path.join(DATADIR, 'goforward.raw'), 'rb')
while True:
buf = stream.read(1024)
if buf:
decoder.process_raw(buf, False, False)
else:
break
decoder.end_utt()

with sr.AudioFile(decoder) as source:
audio = r.record(source) # read the entire audio file

try:
print("TEXT : " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
print("Sphinx could not understand audio")
except sr.RequestError as e:
print("Sphinx error; {0}".format(e))

error - File "SR_decoder.py", line 35, in
decoder = Decoder(config)
File "C:\ProgramData\Anaconda2\lib\site-packages\pocketsphinx\pocketsphinx.py"
, line 273, in init
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1

@vipulsurya vipulsurya changed the title sphinx Decoder error RuntimeError: new_Decoder returned -1 Feb 14, 2019
@vipulsurya
Copy link
Author

hi
i want speech recognition using sphinx but as the accuracy of sphinx is not good at all. so need to decode the wav file but getting some error into the file....can any one please help me on this.
please tell me any alternate way to achieve offline speech recognition...

from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
import speech_recognition as sr
from os import environ,path
from itertools import izip
from pocketsphinx import *
from sphinxbase import *

MODELDIR = "C:/ProgramData/Anaconda2/Lib/site-packages/pocketsphinx/model/"
DATADIR = "C:/ProgramData/Anaconda2/Lib/site-packages/pocketsphinx/data/"

AUDIO_FILE = path.join(path.dirname(path.realpath(file)), "seriously.wav")

r = sr.Recognizer()

config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'hmm/en_US/hub4wsj_sc_8k'))
config.set_string('-lm', path.join(MODELDIR, 'lm/en_US/hub4.5000.DMP'))
config.set_string('-dict', path.join(MODELDIR, 'lm/en_US/hub4.5000.dic'))

decoder = Decoder(config)

decoder = decoder.decode_raw(open(AUDIO_FILE, 'rb'))

hypothesis = decoder.hyp()

for best, i in izip(decoder.nbest(), range(10)):
print best.hyp().best_score, best.hyp().hypstr

decoder = Decoder(config)

#decoder.start_utt('goforward')
decoder.start_utt()
stream = open(path.join(DATADIR, 'goforward.raw'), 'rb')
while True:
buf = stream.read(1024)
if buf:
decoder.process_raw(buf, False, False)
else:
break
decoder.end_utt()

with sr.AudioFile(decoder) as source:
audio = r.record(source) # read the entire audio file

try:
print("TEXT : " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
print("Sphinx could not understand audio")
except sr.RequestError as e:
print("Sphinx error; {0}".format(e))

error - File "SR_decoder.py", line 35, in
decoder = Decoder(config)
File "C:\ProgramData\Anaconda2\lib\site-packages\pocketsphinx\pocketsphinx.py"
, line 273, in init
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1

@vipulsurya vipulsurya reopened this Feb 14, 2019
@ismailryt
Copy link

Hello @vipulsurya, are you already find the solution? If yes can you tell me how to fix that error

And btw, if we mix sphinx and speech recognition library , we can use it offline?

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants