Bonsoir,
Je suis en train d'utiliser pocketsphinx-python pour faire de la reconnaissance vocale.
Je tourne sur raspberry. Après quelques recherches j'ai trouvé un exemple. Le problème c'est que quand je le lance il me dit
ERROR: "pocketsphinx.c", line 1129: Utterance is not started
Traceback (most recent call last):
File "reco.py", line 66, in <module>
decoder.end_utt()
mport sys, os
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
import pyaudio
import wave
import time
#
# constants
SAMPLE_RATE = 16000
CHUNK_SIZE = 1024
print("Setting directories")
#
# Set directories
modeldir = "/home/pi/sphinx/fr-fr"
dictdir = "/home/pi/sphinx/fr-fr"
#
# Create a decoder configeration
config = Decoder.default_config()
config.set_string('-hmm', os.path.join(modeldir, 'fr'))
config.set_string('-lm', os.path.join(modeldir, 'fr-small.lm.bin'))
config.set_string('-dict', os.path.join(dictdir, 'fr.dict'))
config.set_string('-keyphrase', 'talkin to')
config.set_float('-kws_threshold', 1e-5)
#
# create decoder
decoder = Decoder(config)
#
# open the wav file
print("Opening Wav file")
wf = wave.open('/home/pi/sphinx/datas.wav', 'rb');
#
# extract data from wav file
filesize = wf.getnframes() * 2
decoder.start_utt()
#
print "decong"
# tracking variables
index = 0
detected_times = 0
#
# loop for all chunks until the end of the file
while index < filesize:
#
# set number of bytes to CHUNK_SIZE unless that would overrun file size
if (index + 1024) > filesize:
count = (filesize - index)
else:
count = CHUNK_SIZE
#
# take sub set of the data
temp_data = data[index:(index+count)]
#
# process this subset
decoder.process_raw(temp_data, False, False)
#
if decoder.hyp() != None:
#
#increment the keywords detected count
detected_times = detected_times + 1
#
# print out some debug
print("Keyword detected @ ", (index / SAMPLE_RATE), "Seconds: String = ", decoder.hyp().hypstr, ": \
Best score = ", decoder.hyp().best_score, ": confidence = ", decoder.get_logmath().exp(decoder.hyp().prob))
decoder.end_utt()
decoder.start_utt()
#
# update index to take the next subset
index = index + count
# print the number of keywords detected
print("detected times = ", detected_times)
decoder.end_utt()













