我要使用我自己的文件JSGF进行语法检查。 下面,我发布了一段代码:
import os
from pocketsphinx import AudioFile, get_model_path, get_data_path
model_path = get_model_path()
data_path = get_data_path()
config = {
'verbose': False,
'audio_file': os.path.join(data_path,
'/home/mmamonova/sphinx/audio/record-1544774411160.wav'),
'buffer_size': 2048,
'no_search': False,
'full_utt': False,
'hmm': os.path.join(model_path, 'zero_ru.cd_cont_4000'),
'lm': False,
'jsgf': os.path.join(model_path, 'grammar.jsgf'),
'dict': os.path.join(model_path, 'dictionary.dic'),
}
audio = AudioFile(**config)
for phrase in audio:
print(phrase)
启动此代码后,我看到一个错误:
Traceback (most recent call last):
File "app.py", line 65, in <module>
audio = AudioFile(**config)
File "/home/mmamonova/sphinx/env/lib/python3.6/site-
packages/pocketsphinx/__init__.py", line 169, in __init__
super(AudioFile, self).__init__(**kwargs)
File "/home/mmamonova/sphinx/env/lib/python3.6/site-
packages/pocketsphinx/__init__.py", line 90, in __init__
super(Pocketsphinx, self).__init__(config)
File "/home/mmamonova/sphinx/env/lib/python3.6/site-
packages/pocketsphinx/pocketsphinx.py", line 275, in __init__
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1
将路径写入gramar文件时出现此错误。如果我写了一条完整的路线,没有任何变化。
有人有同样的错误吗?我必须纠正什么? 谢谢。