admin管理员组文章数量:1130349
百度语音识别+图灵机器人+python实现智能对话
1、展示效果
对于简单的对话需要普通话比较标准,当然可以设置成四川话,不过对于名字也可能出错,因为近音词太多了。
2、实现过程
2.1、首先获取语音
通俗点讲就是你说话生成语音文件
def save_wave_file(filepath, data):
wf = wave.open(filepath, 'wb')
wf.setnchannels(channels)
wf.setsampwidth(sampwidth)
wf.setframerate(framerate)
wf.writeframes(b''.join(data))
wf.close()
def my_record():
pa = PyAudio()
#打开一个新的音频stream
stream = pa.open(format=paInt16, channels=channels,
rate=framerate, input=True, frames_per_buffer=num_samples)
my_buf = [] #存放录音数据
t = time.time()
print('正在录音...')
while time.time() < t + 4: # 设置录音时间(秒)
#循环read,每次read 2000frames
string_audio_data = stream.read(num_samples)
my_buf.append(string_audio_data)
print('录音结束.')
save_wave_file百度语音识别+图灵机器人+python实现智能对话
1、展示效果
对于简单的对话需要普通话比较标准,当然可以设置成四川话,不过对于名字也可能出错,因为近音词太多了。
2、实现过程
2.1、首先获取语音
通俗点讲就是你说话生成语音文件
def save_wave_file(filepath, data):
wf = wave.open(filepath, 'wb')
wf.setnchannels(channels)
wf.setsampwidth(sampwidth)
wf.setframerate(framerate)
wf.writeframes(b''.join(data))
wf.close()
def my_record():
pa = PyAudio()
#打开一个新的音频stream
stream = pa.open(format=paInt16, channels=channels,
rate=framerate, input=True, frames_per_buffer=num_samples)
my_buf = [] #存放录音数据
t = time.time()
print('正在录音...')
while time.time() < t + 4: # 设置录音时间(秒)
#循环read,每次read 2000frames
string_audio_data = stream.read(num_samples)
my_buf.append(string_audio_data)
print('录音结束.')
save_wave_file版权声明:本文标题:百度语音识别+图灵机器人+python实现智能对话(小爱机器人) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1763750986a2960205.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论