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

相关推荐
Gigavision5 小时前
基于BUAA-MIHR数据集的噪声解耦对比学习算法
人工智能·python·深度学习·算法
IPdodo_5 小时前
跨境 API 调用不稳定怎么办:出口、超时重试与链路监控的实践
网络·python·网络协议
aramae5 小时前
模拟实现strcmp()(C语言)
c语言·开发语言·后端
Madison-No75 小时前
搭建项目测试环境
linux·运维·服务器·python
计算机编程-吉哥6 小时前
YOLO26 vs YOLO11 vs YOLOv8:深度学习咖啡果实成熟度分割系统【计算机毕业设计选题推荐】
人工智能·python·深度学习·yolo·django·毕业设计
泡海椒6 小时前
PDF 表格样式优化:jquick-pdf 边框、圆角、背景色
java·开发语言·pdf
大衛說6 小时前
11 · 异常处理与日志
python
auto_go7 小时前
Python 实战指南(7)——账本动不动就崩?先把“魔法字符串”和“裸报错”干掉
python
Beyond_System|系统之外7 小时前
【学编程】Python基础编程题100道(21-60)
开发语言·python·算法
根目录下的猫7 小时前
RK3588适配的轻量级AI模型推荐
人工智能·后端·python·目标检测