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

相关推荐
青铜发条16 分钟前
【python】python进阶——logging日志模块
python
superlls34 分钟前
(计算机网络)JWT三部分及 Signature 作用
java·开发语言·计算机网络
无规则ai1 小时前
动手学深度学习(pytorch版):第六章节—卷积神经网络(1)从全连接层到卷积
人工智能·pytorch·python·深度学习·cnn
一只鲲1 小时前
56 C++ 现代C++编程艺术5-万能引用
开发语言·c++
秋难降1 小时前
优雅的代码是什么样的?🫣
java·python·代码规范
liulilittle2 小时前
.NET反射与IL反编译核心技术
开发语言·数据库·c#·.net·反射·反编译·il
二闹2 小时前
聊天怕被老板发现?摩斯密码来帮你
后端·python
扛麻袋的少年2 小时前
6.Kotlin的Duration类
android·开发语言·kotlin
mit6.8242 小时前
[RestGPT] OpenAPI规范(OAS)
人工智能·python
360安全应急响应中心3 小时前
Python代码保护之重置操作码映射的攻与防探究(一)
python·逆向