Python 语音语言处理
Daniel Bourke
Machine Learning Engineer/YouTube Creator
一些现有的 Python 库
从 PyPi 安装:
$ pip install SpeechRecognition
# 导入 SpeechRecognition 库 import speech_recognition as sr# 创建 Recognizer 实例 recognizer = sr.Recognizer()# 设置能量阈值 recognizer.energy_threshold = 300
Recognizer 类内置与语音 API 交互的函数recognize_bing()recognize_google()recognize_google_cloud()recognize_wit()输入:audio_file
输出:audio_file 的转写文本
重点:recognize_google()
用 SpeechRecognition 从音频文件识别语音:
# 导入 SpeechRecognition 库 import speech_recognition as sr# 实例化 Recognizer 类 recognizer = sr.Recognizer()# 使用 Google Web API 转写语音 recognizer.recognize_google(audio_data=audio_file language="en-US")
在 DataCamp 学习语音识别太棒了!
Python 语音语言处理