codecamp

AI人工智能 口语词的识别

语音识别是指当人类说话时,机器能够理解它。这里我们在 Python 中使用 Google 语音 API 来实现这一点。我们需要安装以下包:

  • Pyaudio:可以通过pip install pyaudio命令安装。
  • SpeechRecognition:可以通过pip install SpeechRecognition命令安装。
  • Google-Speech-API:可以通过pip install google-api-python-client命令安装。

示例

观察以下示例以理解口语单词识别:

导入必要的包,如下所示:

import speech_recognition as sr

创建一个对象,如下所示:

recording = sr.Recognizer()

现在,Microphone()模块将接收语音作为输入:

with sr.Microphone() as source:
    recording.adjust_for_ambient_noise(source)
    print("Please Say something:")
    audio = recording.listen(source)

现在,Google API 将识别语音并给出输出:

try:
    print("You said: \n" + recording.recognize_google(audio))
except Exception as e:
    print(e)

您可以看到以下输出:

Please Say Something:
You said:

例如,如果您说w3cschool.cn,系统会正确识别为:

w3cschool.cn
AI人工智能 从语音中提取特征
AI 人工智能中启发式搜索的概念
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

AI人工智能监督学习(回归)

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }