Python 智能语音识别的功能

python 复制代码
import speech_recognition as sr

def voice_recognition():
    # 创建语音识别对象
    r = sr.Recognizer()
    # 从麦克风中获取音频
    with sr.Microphone() as source:
        print("Please speak...")
        audio = r.listen(source)
    try:
        # 使用 Google Speech Recognition API 进行识别
        text = r.recognize_google(audio, language='zh-CN')
        print("You said: ", text)
    except sr.UnknownValueError:
        print("Google Speech Recognition could not understand audio")
    except sr.RequestError as e:
        print("Could not request results from Google Speech Recognition service; {0}".format(e))
相关推荐
染指11105 小时前
26.RAG进阶(Advanced RAG)-假设性问题索引
人工智能·windows·agent·rag·advanced rag
闵孚龙5 小时前
动态图机制:为什么 PyTorch 调试起来更舒服
人工智能·pytorch·python
chushiyunen6 小时前
langchain4j笔记、tools
笔记·python·flask
甲维斯6 小时前
还要啥Codex!DeepSeek接入Zcode远程连接!
人工智能
百胜软件@百胜软件6 小时前
百胜软件亮相“AI消费新生活”主题日活动,AI智能运营平台入选市级案例征集
人工智能·生活·零售数字化·数智中台·珠宝行业
程序员三藏6 小时前
Web自动化测试详解
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
在放️7 小时前
Python 爬虫 · 第三方代理接入与合规使用
开发语言·爬虫·python
专注搞钱7 小时前
GPT-4o写设备Recipe:从3小时到10分钟
数据库·人工智能·gpt·半导体
闻道参看7 小时前
贝芯宠AI灵兽 ELFVET 大模型聚焦临床应用,强化宠物诊疗综合能力
人工智能·宠物
MartinYeung57 小时前
[论文学习]重新思考大型语言模型忘却目标:梯度视角与超越
人工智能·学习·语言模型