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))
相关推荐
Summer-Bright6 小时前
深度 | AI 早期融资的估值前置:种子轮买人,A 轮买营收,安全边际在消失
人工智能·安全
会灭火的程序员6 小时前
大模型部署硬件资源计算指南:从显存估算到显卡选型
人工智能·算法
LittroInno6 小时前
AI云台相机如何协同成像 识别 跟踪与运动
人工智能·数码相机·计算机视觉·目标跟踪·目标识别·云台相机
dd聊技术6 小时前
给检索改动装一盏红绿灯:评测门禁怎么建、怎么用
人工智能·后端
chipsense6 小时前
电焊机电源的电流检测:为什么你的焊缝总是不稳定
人工智能·霍尔电流传感器·电流检测·电焊机
鬓戈6 小时前
AI基础之神经网络
人工智能·深度学习·神经网络
空 白II6 小时前
10.14 大语言模型研究简报:Anthropic 推出反蒸馏防御
人工智能·语言模型·归因报告
XZ-0700016 小时前
week8-代码解析2
python