【教程】极简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/

相关推荐
http阿拉丁神猫2 小时前
Go语言入门笔记:从基础到开发环境搭建(二)
开发语言·笔记·golang
不会就选b3 小时前
C++补充部分(一)--lambda 表达式
开发语言·c++
4SAPI4 小时前
多模型请求路由怎么设计?成本、速度和能力如何平衡
人工智能·python·gateway·php
Pniubi5 小时前
HashMap的扩容和树化边界
java·开发语言
XCDoris6 小时前
郴州logo设计机构
大数据·人工智能·python
gCode Teacher 格码致知7 小时前
Pandas教学-17:Series与Dataframe的关系
开发语言·python·pandas
发量惊人的中年网工7 小时前
分公司访问总部ERP慢怎么办?SD-WAN组网的排查与验收要点
服务器·开发语言·php
下页、再停留7 小时前
【C#桌面客户端系列学习-15】生成可视化图表之折线图、柱状图、饼状图
开发语言·c#
ShineWinsu8 小时前
对于JavaScript:操作元素的解析
开发语言·前端·javascript·面试·web·dom·元素
马良神笔8 小时前
2026 年Rag最近技术前沿总结
后端·python·django