python音频转文字speech recognition_使用SpeechRecognition进行语音识别
操作系統 : CentOS7.7.1908_x64
gcc版本 :4.8.5
Python 版本 : 3.6.8
安裝語音識別環境:
virtualenv?-p?/usr/bin/python3?py36asr
source?py36asr/bin/activate
pip?install?SpeechRecognition
yum?install?python3-devel
yum?install?pulseaudio-libs-devel
yum?install?alsa-lib-devel
pip?install??PocketSphinx
配置中文語音識別數據:
下載地址:
https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/
選擇: Mandarin->cmusphinx-zh-cn-5.2.tar.gz
配置數據:cd?py36asr/lib/python3.6/site-packages/speech_recognition/pocketsphinx-data/
tar?zxvf?cmusphinx-zh-cn-5.2.tar.gz
mv?cmusphinx-zh-cn-5.2?zh-cn
cd?zh-cn
mv?zh_cn.cd_cont_5000?acoustic-model
mv?zh_cn.lm.bin?language-model.lm.bin
mv?zh_cn.dic?pronounciation-dictionary.dict
測試文本:
自然語言理解和生成是一個多方面問題,我們對它可能也只是部分理解。
語音識別示例:
(py36asr)?[root@host60?pyasrTest1]#?ls
test1.py??test1.wav
(py36asr)?[root@host60?pyasrTest1]#?cat?test1.py
#?-*-?coding:?utf-8?-*-
#?/usr/bin/python
import?speech_recognition?as?sr
r?=?sr.Recognizer()
test?=?sr.AudioFile("test1.wav")
with?test?as?source:
audio?=?r.record(source)
type(audio)
c=r.recognize_sphinx(audio,?language='zh-cn')
print(c)
(py36asr)?[root@host60?pyasrTest1]#?python?test1.py
自然?語言?李杰?和?申城?是一?個?多方?面?問題?我們?對?他?可能?也?只是?部分?禮節
(py36asr)?[root@host60?pyasrTest1]#
本文涉及資源下載地址:https://pan.baidu.com/s/1Out0tJlb_Qs-2C06_2YHOQ
可關注微信公眾號(聊聊博文)后回復 2020062101 獲取提取碼。
本文github地址:
https://github.com/mike-zhang/mikeBlogEssays/blob/master/2020/20200621_使用SpeechRecognition進行語音識別.rst????更多Python相關文章,請關注云海天python教程網。
總結
以上是生活随笔為你收集整理的python音频转文字speech recognition_使用SpeechRecognition进行语音识别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 3dvary灯光材质为什么不亮_装修小白
- 下一篇: 2022年商贷买房利率,有以下两种利率详