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

相关推荐
tryCbest3 分钟前
Java和Python开发项目部署简介
java·开发语言·python
ZTLJQ4 分钟前
任务调度的艺术:Python分布式任务系统完全解析
开发语言·分布式·python
阿里嘎多学长5 分钟前
2026-03-31 GitHub 热点项目精选
开发语言·程序员·github·代码托管
敏编程10 分钟前
一天一个Python库:isodate - 处理 ISO 8601 日期时间格式
python
小只笨笨狗~14 分钟前
解决objectSpanMethod与expand共存时展开后表格错位问题
开发语言·javascript·ecmascript
比昨天多敲两行19 分钟前
C++ AVL树
开发语言·c++
Bert.Cai25 分钟前
Python字面量详解
开发语言·python
Flying pigs~~27 分钟前
基于Deepseek大模型API完成文本分类预测功能
java·前端·人工智能·python·langchain·deepseek
Lyyaoo.28 分钟前
【JAVA基础面经】深拷贝与浅拷贝
java·开发语言·算法