WangFeng/2023
参考 https://alphacephei.com/vosk/index.zh。
Vosk是语言识别工具包。支持二十多种语言、移动设备上离线工作,模型50Mb。
docker run -d -p 2700:2700 alphacep/kaldi-cn
如果使用移动设备的包
wget https://alphacephei.com/vosk/models/vosk-model-small-cn-0.22.zip
docker run -d -p 2700:2700 -v /opt/model:/opt/vosk-model-en/model alphacep/kaldi-cn
大体步骤如下:
1、安装libks
https://github.com/signalwire/libks
2、安装freeswitch,包括mod_vosk.so
https://github.com/alphacep/freeswitch/tree/master/src/mod/asr_tts/mod_vosk
mod_vosk.so放在/usr/local/freeswitch/mod下。
3、modules.conf.xml中启用mod_vosk.so
修改modules.conf.xml
,开启<load module="mod_vosk"/>
4、conf/autoload_configs中新增vosk.conf.xml
vosk.conf.xml
,更改server-url
为docker的vosk。
configuration name="vosk.conf" description="Vosk ASR Configuration">
<settings>
<param name="server-url" value="ws://localhost:2700"/>
<param name="return-json" value="0"/>
<settings>
</configuration> </
5、修改拨号计划
extension name="asr_demo">
<condition field="destination_number" expression="^.*$">
<action application="export" data="fire_asr_events=true"/>
<action application="detect_speech" data="vosk default default"/>
<action application="bridge" data="{execute_on_media=detect_speech vosk default default}sofia/external/${destination_number}@ip:端口"/>
<condition>
</extension> </
6、FreeSWITCH重启后,reload mod_vosk
nc 127.0.0.1 8021
auth ClueCon
event plain DETECTED_SPEECH