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

相关推荐
2303_821287386 分钟前
如何清洗SQL输入数据_使用框架内置的ORM处理数据交互
jvm·数据库·python
go不是csgo9 分钟前
s01 搭建第一个对话智能体
服务器·网络·python·ai
用户83562907805112 分钟前
使用 Python 在 PowerPoint 中生成并自定义饼图与环形图
后端·python
棉猴15 分钟前
python海龟绘图之倾转
python·turtle·海龟绘图·titlangle·tilt
念何架构之路19 分钟前
Go语言常见并发模式
开发语言·后端·golang
磊 子41 分钟前
多态类原理+四种类型转换+异常处理
开发语言·c++·算法
脆皮炸鸡75543 分钟前
库制作与原理~动态链接
linux·开发语言·经验分享·笔记·学习方法
XMYX-044 分钟前
26 - Go recover 捕获错误:优雅恢复的真正意义
开发语言·golang
小白学大数据1 小时前
基于大模型的Python智能爬虫:语义识别与数据清洗实践
开发语言·爬虫·python·数据分析