I am trying to recognize the words of an audio that is in Spanish, I followed the steps of this guide: https://github.com/Uberi/speech_recognition/blob/master/reference/pocketsphinx.rst#installing-other-languages. I can configure the folder for another language and I gave the name: es-PE and use this example code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3

import speech_recognition as sr

# obtain path to "english.wav" in the same folder as this script
from os import path
AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "prueba1.wav")
# AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "french.aiff")
# AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "chinese.flac")

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

r.recognize_sphinx(audio, language = "es-PE")

# recognize speech using Sphinx
try:
    print("Sphinx thinks you said " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
    print("Sphinx could not understand audio")
except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))

when running this code I get the following error:

Traceback (most recent call last):
  File "audio_transcribe.py", line 17, in <module>
    r.recognize_sphinx(audio, language = "es-PE")
  File "/usr/lib/python3.6/site-packages/speech_recognition/__init__.py", line 671, in recognize_sphinx
    raise RequestError("missing PocketSphinx language model file: \"{}\"".format(language_model_file))
speech_recognition.RequestError: missing PocketSphinx language model file: "/usr/lib/python3.6/site-packages/speech_recognition/pocketsphinx-data/es-PE/language-model.lm.bin"

My question is how to configure the language parameter correctly in the code and if the error that comes out is due to that or my language model is wrong.
Thanks for your time.