【教程】极简Python接入免费语音识别API

转载请注明出处:小锋学长生活大爆炸[xfxuezhagn.cn]

如果本文帮助到了你,请不吝给个[点赞、收藏、关注]哦~

安装库:

bash 复制代码
pip install SpeechRecognition

使用方法:

python 复制代码
import speech_recognition as sr

r = sr.Recognizer()
harvard = sr.AudioFile('harvard.wav')
with harvard as source:
    r.adjust_for_ambient_noise(source, duration=0.5)
    audio = r.record(source)

text = r.recognize_google(audio, language='zh-cn')
print(text)

完整教程可参考:

The Ultimate Guide To Speech Recognition With Python -- Real PythonAn in-depth tutorial on speech recognition with Python. Learn which speech recognition library gives the best results and build a full-featured "Guess The Word" game with it.https://realpython.com/python-speech-recognition/

相关推荐
Turnsole_y1 小时前
pycharm自动化测试初始化
python·selenium
R-G-B1 小时前
【02】C#入门到精通——C# 变量、输入/输出、类型转换
开发语言·c#·c# 变量·c#输入/输出·c#类型转换
星河队长1 小时前
C# 软件加密方法,有使用时间限制,同时要防止拷贝
开发语言·c#
史迪奇_xxx1 小时前
10、一个简易 vector:C++ 模板与 STL
java·开发语言·c++
2301_801252221 小时前
Java中的反射
java·开发语言
Kiri霧2 小时前
Rust开发环境搭建
开发语言·后端·rust
weixin-a153003083162 小时前
[数据抓取-1]beautifulsoup
开发语言·python·beautifulsoup
AI量化投资实验室2 小时前
15年122倍,年化43.58%,回撤才20%,Optuna机器学习多目标调参backtrader,附python代码
人工智能·python·机器学习
倔强青铜三2 小时前
苦练Python第67天:光速读取任意行,linecache模块解锁文件处理新姿势
人工智能·python·面试
小杨同学yx3 小时前
有关maven的一些知识点
java·开发语言