Enregistrez un exemple de fichier hola.wav
au format 16 kHz 16 bits mono.
Installez ensuite pocketsphinx-python
sudo apt-get install -y python python-dev python-pip build-essential swig git
git clone --recursive https://github.com/cmusphinx/pocketsphinx-python
cd pocketsphinx-python
sudo python setup.py install
Ensuite, téléchargez espagnol models du site cmusphinx.
Ensuite, écrire un script et essayer de l'exécuter, il devrait ressembler à ceci:
#!/usr/bin/env python
from os import environ, path
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
# Here is the configuration for Spanish
config = Decoder.default_config()
config.set_string('-hmm', 'cmusphinx-es-5.2/model_parameters/voxforge_es_sphinx.cd_ptm_4000')
config.set_string('-lm', 'es-20k.lm.gz')
config.set_string('-dict', 'es.dict')
decoder = Decoder(config)
# Decode streaming data.
decoder = Decoder(config)
decoder.start_utt()
stream = open('hola.wav', 'rb')
while True:
buf = stream.read(1024)
if buf:
decoder.process_raw(buf, False, False)
else:
break
decoder.end_utt()
print ('Best hypothesis segments: ', [seg.word for seg in decoder.seg()])
Pour en savoir plus sur CMUSphinx lire le tutorial.