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

相关推荐
caimouse24 分钟前
Reactos 第 4 章 对象管理 — 4.8 系统调用 NtDuplicateObject / 4.9 系统调用 NtClose
开发语言·windows·架构
GDAL28 分钟前
uv 完整教程:下一代 Python 包管理工具
python·uv
曲幽8 小时前
FastAPI 身份验证总踩坑?这份 FastAPI Users “避坑指南”请收好
python·fastapi·web·jwt·oauth2·user·authentication
xieliyu.8 小时前
Java算法精讲:双指针(二)
java·开发语言·算法
装不满的克莱因瓶8 小时前
掌握 RNN 与 LSTM 模型结构
人工智能·python·rnn·深度学习·神经网络·ai·lstm
何以解忧,唯有..8 小时前
Python包管理工具pip:从入门到精通
开发语言·python·pip
雪的季节9 小时前
RabbitMQ详解
开发语言
金銀銅鐵9 小时前
用 Tkinter 实现简单的猜数字游戏
后端·python
copyer_xyf9 小时前
Python 模块与包的导入导出
前端·后端·python
ice8130331819 小时前
【Python】Matplotlib折线图绘制
开发语言·python·matplotlib