Pocketsphinx new_Decoder 错误,无法将新语言添加到实时语音中,如何解决?

问题描述

我下载了新的语言包并像在 github https://github.com/bambocher/pocketsphinx-python 中一样设置了所有内容,但出现此错误

Traceback (most recent call last):
  File "D:\Dev\PetProjects\PythonPetProjects\Darling\darling\main.py",line 39,in <module>
    main()
  File "D:\Dev\PetProjects\PythonPetProjects\Darling\darling\main.py",line 18,in main
    speech = LiveSpeech(
  File "C:\Users\PANDEMIC\AppData\Local\pypoetry\Cache\virtualenvs\darling-0MBR-P4T-py3.9\lib\site-packages\pocketsphinx\__init__.py",line 208,in __init__
    super(LiveSpeech,self).__init__(**kwargs)
  File "C:\Users\PANDEMIC\AppData\Local\pypoetry\Cache\virtualenvs\darling-0MBR-P4T-py3.9\lib\site-packages\pocketsphinx\__init__.py",line 90,in __init__
    super(Pocketsphinx,self).__init__(config)
  File "C:\Users\PANDEMIC\AppData\Local\pypoetry\Cache\virtualenvs\darling-0MBR-P4T-py3.9\lib\site-packages\pocketsphinx\pocketsphinx.py",line 273,in __init__
    this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1

我的语言包https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/Russian/zero_ru_cont_8k_v3.tar.gz/download?use_mirror=altushost-swe&download=&failedmirror=deac-riga.dl.sourceforge.net

我的代码

import os

from pocketsphinx import LiveSpeech,get_model_path



BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SOURCES = os.path.join(BASE_DIR,'src')




def main():
    print('Darling is runnig')

    ru_model_path = os.path.join(get_model_path(),'ru-ru')

    speech = LiveSpeech(
        verbose=False,sampling_rate=16000,buffer_size=2048,no_search=False,full_utt=False,hmm=ru_model_path,lm=os.path.join(ru_model_path,'ru.lm'),dic=os.path.join(ru_model_path,'ru.dic')
    )

if __name__ == '__main__':
    main()

解决方法

在较新版本的sphinx中,您无法添加您的语言包,您可以使用谷歌识别,或重建您的包。