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

相关推荐
s***469810 分钟前
【玩转全栈】----Django模板语法、请求与响应
数据库·python·django
风生u33 分钟前
go进阶语法
开发语言·后端·golang
666HZ66635 分钟前
C语言——黑店
c语言·开发语言
Gomiko41 分钟前
JavaScript基础(八):函数
开发语言·javascript·ecmascript
runepic1 小时前
Python + PostgreSQL 批量图片分发脚本:分类、去重、断点续拷贝
服务器·数据库·python·postgresql
〝七夜5691 小时前
JVM内存结构
java·开发语言·jvm
初级炼丹师(爱说实话版)1 小时前
JAVA泛型作用域与静态方法泛型使用笔记
java·开发语言·笔记
codists1 小时前
2025年11月文章一览
python
生而为虫1 小时前
31.Python语言进阶
python·scrapy·django·flask·fastapi·pygame·tornado
言之。1 小时前
Claude Code 实用开发手册
python