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))
相关推荐
miofly7 小时前
EmbeddingGemma 2:740M 参数的多模态嵌入模型,支持本地推理
人工智能
YOLO数据集集合7 小时前
桥梁损伤实例分割数据集 | 桥梁损伤 实例分割 裂缝检测 钢筋外露 混凝土剥落9160期
人工智能·目标检测·计算机视觉·桥梁·桥梁损害·桥梁数据集
DongQiShanRen7 小时前
裁决台账双向互校(下):台账哈希链、三向对账与最小落地
人工智能·深度学习·算法·目标跟踪·自然语言处理·rust·哈希算法
空心木偶☜7 小时前
LangChain 概述
python·ai·langchain·ai编程
兆。7 小时前
【无标题】
人工智能
LaughingZhu7 小时前
Product Hunt 每日热榜 | 2026-10-02
数据库·人工智能·深度学习·神经网络·搜索引擎
听风吹等浪起7 小时前
第22章:YOLOv5船舶目标检测+注意力模块改进对比,卫星遥感船舶识别实战
人工智能·yolo·目标检测
niaonao7 小时前
C盘爆红别乱删!我用 Codex 查出 AppData 占了 87.81GB
人工智能·openai
lie..7 小时前
30天从零开始学AI应用开发(Day 19):项目二完结:RAG 知识库问答系统,把自己攒的资料变成私人顾问
开发语言·人工智能·python
深度之眼7 小时前
深度学习研0研1如何正确 “阅读文献” ?分享 “3步高效阅读法” !
人工智能·深度学习