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

本文标签: 机器人小爱语音识别智能图灵