Exemplo n.º 1
0
 def s_callback(in_data, frame_count, time_info, status):
   print "s_callback"
   (output, clean, flac) = get_filenames()
   record_wave(output, in_data)
   audioProcess.clean_audio(output, clean, flac)
   r = speechText.speech_to_txt(flac)
   hypotheses = r.get('hypotheses', [])
   utterance = ''
   confidence = 0
   if (len(hypotheses) > 0):
     utterance = (hypotheses[0]).get('utterance')
     confidence = float((hypotheses[0]).get('confidence'))
   print "Utterance: %s"%(utterance)
   msg = SpeechAPIResponse(hypothesis=utterance, confidence = confidence)
   pubWords.publish(msg)
   #publish r to 'wordsHeard'
   return (in_data, pyaudio.paContinue)
Exemplo n.º 2
0
 def s_callback(in_data, frame_count, time_info, status):
   print "s_callback"
   (output, clean, flac) = get_filenames()
   record_wave(output, in_data)
   audioProcess.clean_audio(output, clean, flac)
   r = speechText.speech_to_txt(flac)
   hypotheses = r.get('hypotheses', [])
   utterance = ''
   confidence = 0
   if (len(hypotheses) > 0):
     utterance = (hypotheses[0]).get('utterance')
     confidence = float((hypotheses[0]).get('confidence'))
   print "Utterance: %s"%(utterance)
   msg = SpeechAPIResponse(hypothesis=utterance, confidence = confidence)
   pubWords.publish(msg)
   #try:
   #  os.remove(output)
   #  os.remove(clean)
   #  os.remove(flac)
   #except:
   #  rospy.logerr("Error trying to remove temporary saved files")
   return (in_data, pyaudio.paContinue)