语音识别学习案例记录

发布时间:2024-11-22 17:23

学会利用语音识别软件记录重要信息 #生活技巧# #沟通技巧# #在线沟通方式#

语音识别学习案例记录

最新推荐文章于 2024-01-18 02:04:30 发布

拍拍肚子 于 2020-08-07 16:52:33 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

 playsound和simpleaudio:

https://www.jianshu.com/p/9412ae6c70bd

识别音频中的内容:

import speech_recognition as sr

r = sr.Recognizer()

with sr.AudioFile('audio_files/harvard.wav') as source:

audio = r.record(source,offset=4.7,duration=2.8)

print(r.recognize_sphinx(audio))

record()

>> 音頻文件中獲取數據

recognize_bing(): Microsoft Bing Speech

recognize_google(): Google Web Speech API

recognize_google_cloud(): Google Cloud Speech - requires installation of the google-cloud-speech package

recognize_houndify(): Houndify by SoundHound

recognize_ibm(): IBM Speech to Text

recognize_sphinx(): CMU Sphinx - requires installing PocketSphinx

recognize_wit(): Wit.ai

>> Recognizer API主要用於 - 識別語音

>> 每個API都有多個設置 和 功能來識別音頻源的語音

>> recognition_sphinx()

>> 可以 與 CMU Sphinx引擎 offline 工作

>> 其他六個需要連接online 到 Internet

识别麦克风中输入的内容:

import speech_recognition as sr

r = sr.Recognizer()

mic = sr.Microphone()

with mic as source:

# 调整噪音

r.adjust_for_ambient_noise(source)

audio = r.listen(source)

print(r.recognize_sphinx(audio))

播放文本声音:

import pyttsx3

engine = pyttsx3.init()

engine.say('hello world')

engine.runAndWait()

播放wav格式文件中的声音:

import simpleaudio as sa

wave_obj = sa.WaveObject.from_wave_file("audio_files/harvard.wav") # harvard.wav

play_obj = wave_obj.play()

play_obj.wait_done()

from gtts import gTTS

from playsound import playsound

hubei = '你好,湖北'

obj = gTTS(text=hubei, slow=False, lang='zh-tw')

obj.save('audio_files/hubei.mp3')

playsound('audio_files/hubei.mp3')

import tempfile

from gtts import gTTS

from pygame import mixer

import speech_recognition

def listenTo():

r = speech_recognition.Recognizer()

with speech_recognition.Microphone() as source:

r.adjust_for_ambient_noise(source)

audio = r.listen(source)

return r.recognize_sphinx(audio)

# return r.recognize_google(audio, language='zh-TW')

mixer.init()

def speak(sentence):

with tempfile.NamedTemporaryFile(delete=True) as fp:

tts = gTTS(text=sentence, lang='zh-tw')

tts.save("{}.mp3".format(fp.name))

mixer.music.load('{}.mp3'.format(fp.name))

mixer.music.play()

Answer = {

'你好吗': '我很好',

'你很帥': '谢谢啦 !',

'再见了': '下次见了! 再聊 ! 拜拜'

}

speak(Answer.get(listenTo(), '对不起,听不清楚!请再说一遍,谢谢啦!再回答你'))

网址:语音识别学习案例记录 https://www.yuejiaxmz.com/news/view/195076

相关内容

语音识别应用案例 | 语音助手
AI智能语音识别助手:实时录音转文字及多样化转录解决方案
实战案例:AI在语音识别与语音合成领域的应用
【深度学习】深度学习语音识别算法的详细解析
深度学习与语音识别:深度学习如何驱动语音助手的发展
语音识别与语音助手:机器学习的生活实践
语音识别方案
'智能语音识别助手:一键转换语音为精准文案软件'
语音识别公司排名
语音识别技术已经广泛应用在学习、生活和工作中,以下属于语音识别技术应用的是()

随便看看