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

相关推荐
alphaTao30 分钟前
LeetCode 每日一题 2026/7/27-2026/8/2
python·算法·leetcode
易筋紫容1 小时前
创建型模式:对象的诞生艺术
开发语言·前端·javascript
888CC++1 小时前
C++ 快速学习指南:从入门到进阶的实战路线
开发语言·c++
Kevin Wang7271 小时前
Nvidia-AGX-spark部署手册——课堂质量诊断(jetpack:r36)
python·docker·容器
小小晓.1 小时前
C++记:函数
开发语言·c++·算法
牡丹雅忻11 小时前
AES 加密模式演进:从 ECB、CBC 到 GCM 的 C# 深度实践
java·开发语言·c#
连续讨伐1 小时前
php小结
开发语言·php
进击的程序猿~2 小时前
Go 并发底层原理面试学习指南
开发语言·面试·golang
Python私教2 小时前
Django 6.1 RC1 实测:FETCH_PEERS 两条 SQL 解决 N+1,select_related 还需要吗?
后端·python·django
脚踏实地皮皮晨2 小时前
002002002_DepandencyObject类2
开发语言·windows·算法·c#·visual studio