Nehmen Sie eine Beispieldatei hola.wav
mit dem Format 16khz 16bit mono auf.
Dann pocket-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
downloaden Dann Spanisch models von cmusphinx Website installieren.
Dann ein Skript schreiben und versuchen, es zu laufen, es sollte wie folgt aussehen:
#!/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()])
mehr erfahren über CMUSphinx die tutorial lesen.