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

相关推荐
西阳未落3 分钟前
C语言柔性数组详解与应用
c语言·开发语言·柔性数组
Huhbbjs4 分钟前
SQL 核心概念与实践总结
开发语言·数据库·sql
大翻哥哥4 分钟前
Python 2025:低代码开发与自动化运维的新纪元
运维·python·低代码
咕噜咕噜啦啦17 分钟前
Qt之快捷键、事件处理、自定义按键——完成记事本项目
开发语言·qt
Source.Liu20 分钟前
【Pywinauto库】12.2 pywinauto.element_info 后端内部实施模块
windows·python·自动化
Source.Liu20 分钟前
【Pywinauto库】12.1 pywinauto.backend 后端内部实施模块
开发语言·windows·python·自动化
晚云与城24 分钟前
今日分享:C++ deque与priority_queue
开发语言·c++
半梦半醒*26 分钟前
正则表达式
linux·运维·开发语言·正则表达式·centos·运维开发
用户83562907805127 分钟前
用Python高效处理Excel数据:Excel数据读取指南
后端·python
不吃洋葱.1 小时前
Bean.
java·开发语言