import pyaudio
import wave
import sphinxbase
import os
from os import environ, path
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
from scipy.io import wavfile
import logging
config=pocketsphinx.Decoder.default_config()config.set_string('-hmm',HMDIR)config.set_string('-lm',LMDIR)config.set_string('-dict',DICTD)decoder=Decoder(config)speech_rec=pocketsphinx.Decoder(config)opened_file=open(fp)print("\n""types results",type(opened_file),"\n\n")opened_file.seek(44)data=opened_file.read()print("value of data",data)decoder.start_utt()decoder.process_raw(data,False,True)print("value of process_raw",decoder.process_raw(data,False,True))#decoder.end_utt()result=decoder.hyp()print("our results",result)transcribed=[result]logging.info('PocketSphinx ?????%r',transcribed)returntranscribed
if name == 'main':
save_audio(WAVE_OUTPUT_FILENAME)
print(type(WAVE_OUTPUT_FILENAME))
result = transcribe(WAVE_OUTPUT_FILENAME)
print "You just said: {0}".format(result[0])
i didn,t get any error but also not getting OUTPUT below is results when i say "hello world"
i want : to be written text "hello world" after You just said:
\xff\xf3\xff\xda\xff\xc7\xff\xcc\xff\xc8\xff\xb0\xff\xb2\xff\x9e\xff\x9e\xff\xb2\xff\xc0\xff\xcb\xff\xca\xff\xb3\xff\xa1\xffs\xff\\\xffI\xff5\xff\x1f\xff\x03\xff\x11\xff\xf7\xfe\xe3\xfe\xd0\xfe\xe2\xfe\xe7\xfe\xd3\xfe\xb3\xfe\xa2\xfe\xad\xfe\xba\xfe\xcb\xfe\xd1\xfe\xb7\xfe\xa6\xfe\x99\xfeg\xfe]\xfe5\xfe\x19\xfe\x10\xfe\xfe\xfd\xf7\xfd\xf9\xfd\xfb\xfd\xf6\xfd\xf9\xfd\xf3\xfd\xd9\xfd\xcb\xfd\xcb\xfd\xd4\xfd\xd0\xfd\xb4\xfd\xa9\xfd\xac\xfd\xa6\xfd\xa5\xfd\x9c\xfd\x8e\xfdz\xfdr\xfde\xfdn\xfdk\xfdg\xfda\xfdO\xfdM\xfd:\xfd \xfd\x1f\xfd\x1a\xfd1\xfd#\xfd#\xfd\x18\xfd \xfd-\xfdE\xfdc\xfdu\xfd')
INFO: cmn.c(133): CMN: 56.32 5.42 -6.32 -0.67 2.31 8.66 -7.86 12.76 0.48 7.76 -1.23 -2.60 -0.02
INFO: cmn.c(133): CMN: 59.70 4.58 -7.47 -0.79 2.90 10.03 -8.61 13.88 0.58 7.44 -1.23 -2.84 -0.44
('value of process_raw', 339)
('our results', None)
INFO: ngram_search_fwdtree.c(429): TOTAL fwdtree 0.00 CPU -nan xRT
INFO: ngram_search_fwdtree.c(432): TOTAL fwdtree 0.00 wall -nan xRT
INFO: ngram_search_fwdflat.c(176): TOTAL fwdflat 0.00 CPU -nan xRT
INFO: ngram_search_fwdflat.c(179): TOTAL fwdflat 0.00 wall -nan xRT
INFO: ngram_search.c(303): TOTAL bestpath 0.00 CPU -nan xRT
INFO: ngram_search.c(306): TOTAL bestpath 0.00 wall -nan xRT
INFO: ngram_search_fwdtree.c(429): TOTAL fwdtree 0.00 CPU -nan xRT
INFO: ngram_search_fwdtree.c(432): TOTAL fwdtree 0.00 wall -nan xRT
INFO: ngram_search_fwdflat.c(176): TOTAL fwdflat 0.00 CPU -nan xRT
INFO: ngram_search_fwdflat.c(179): TOTAL fwdflat 0.00 wall -nan xRT
INFO: ngram_search.c(303): TOTAL bestpath 0.00 CPU -nan xRT
INFO: ngram_search.c(306): TOTAL bestpath 0.00 wall -nan xRT
You just said: None
waiting for your valuable reply
thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi,
i used below code for speech recognition
import pyaudio
import wave
import sphinxbase
import os
from os import environ, path
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
from scipy.io import wavfile
import logging
try:
import pocketsphinx
except ValueError:
import pocketsphinx
BASE_PATH = os.path.dirname(os.path.realpath(file))
print(BASE_PATH)
HMDIR = os.path.join(BASE_PATH, "hmm")
print(HMDIR)
LMDIR = os.path.join(BASE_PATH, "lm/en-us.lm.bin")
print(LMDIR)
DICTD = os.path.join(BASE_PATH, "dict/cmu07a.dic")
print(DICTD)
CHUNK = 128
FORMAT = pyaudio.paInt16
RATE = 44100
RECORD_SECONDS = 2
WAVE_OUTPUT_FILENAME = "output.wav"
def find_device(p, tags):
def save_audio(wav_file):
def transcribe(fp):
if name == 'main':
save_audio(WAVE_OUTPUT_FILENAME)
print(type(WAVE_OUTPUT_FILENAME))
result = transcribe(WAVE_OUTPUT_FILENAME)
print "You just said: {0}".format(result[0])
INFO: cmn.c(133): CMN: 56.32 5.42 -6.32 -0.67 2.31 8.66 -7.86 12.76 0.48 7.76 -1.23 -2.60 -0.02
INFO: cmn.c(133): CMN: 59.70 4.58 -7.47 -0.79 2.90 10.03 -8.61 13.88 0.58 7.44 -1.23 -2.84 -0.44
('value of process_raw', 339)
('our results', None)
INFO: ngram_search_fwdtree.c(429): TOTAL fwdtree 0.00 CPU -nan xRT
INFO: ngram_search_fwdtree.c(432): TOTAL fwdtree 0.00 wall -nan xRT
INFO: ngram_search_fwdflat.c(176): TOTAL fwdflat 0.00 CPU -nan xRT
INFO: ngram_search_fwdflat.c(179): TOTAL fwdflat 0.00 wall -nan xRT
INFO: ngram_search.c(303): TOTAL bestpath 0.00 CPU -nan xRT
INFO: ngram_search.c(306): TOTAL bestpath 0.00 wall -nan xRT
INFO: ngram_search_fwdtree.c(429): TOTAL fwdtree 0.00 CPU -nan xRT
INFO: ngram_search_fwdtree.c(432): TOTAL fwdtree 0.00 wall -nan xRT
INFO: ngram_search_fwdflat.c(176): TOTAL fwdflat 0.00 CPU -nan xRT
INFO: ngram_search_fwdflat.c(179): TOTAL fwdflat 0.00 wall -nan xRT
INFO: ngram_search.c(303): TOTAL bestpath 0.00 CPU -nan xRT
INFO: ngram_search.c(306): TOTAL bestpath 0.00 wall -nan xRT
You just said: None
waiting for your valuable reply
thanks in advance
i think the reason is that decoder.hyp() does not contains anything will someone please suggest that what to do
i think the reason is that decoder.hyp() does not contains anything will someone please suggest that what to do
i resolved the issue by the way thanks lets close the discussion