gui_manager_thread = threading.Thread( target = gui_manager.gui.main )

# Start the dialog manager
dm = tbh_dialog_manager.tbh_dialog_manager_t()
dm.add_processed_nbest_event_handler( gui_manager.execute_action_handler )

# Start speech recognizer
# It does not need to be on its own thread
sr = tbh_speech_recognizer.tbh_speech_recognizer_t()
sr.add_processed_audio_event_handler( gui_manager.show_nbest_handler )
sr.add_processed_audio_event_handler( gui_manager.system_message_handler )

sr.add_processed_audio_event_handler( dm.process_nbest_handler )

# Add handlers to the tbh_audio_listener
al = tbh_audio_listener.tbh_audio_listener_t()
al.add_audio_listener_handler( sr.process_raw_audio_handler )
al.add_audio_listener_handler( gui_manager.end_of_audio_stream_handler )
al.add_start_of_audio_handler( gui_manager.start_of_audio_handler )

# Add handlers to the speech recognizer


al_thread = threading.Thread( target=al.run )
al_thread.start()



# Add a speech recognizer function to the thread

示例#2
0
feature_type_list = [ 'tbh_keyword' , 'tbh_first_word' , 'tbh_keyword_sequence', 'score_statistic', 'tbh_digits', 'tbh_skype_contact' ]
dm = tbh_dialog_manager.tbh_dialog_manager_t( feature_type_list = feature_type_list, \
                                                  skype_contacts_dict = \
                                                  skype_contacts_dict )

# Initialize speech recognizer
sr = tbh_speech_recognizer.tbh_speech_recognizer_t( \
    starting_grammar = 'full', default_grammar = 'full' )

# Initialize Skype manager
# Pass in the text file containing the contact names
sm = tbh_skype_interface.tbh_skype_interface_t( contacts_file = skype_contacts_dict )

# Initialize the audio listener, has its own thread
al = tbh_audio_listener.tbh_audio_listener_t( \
    microphone_name = 'stereo', temp_audio_storage_path = \
        '../../tbh_top_level/audio_files' )
al_thread = threading.Thread( target=al.run )
al_thread.start()

# Initialize the storage module
ds = tbh_data_storage.tbh_data_storage_t( '../logfiles' )

# ---- SET UP CALLBACKS ---- #
# 1. Once the audio listener has created an utterance, it passes an
# audio WAV file to the speech recognizer, saves the audio
al.add_end_of_audio_handler( sr.process_raw_audio_handler )
al.add_poll_audio_handler( dm.process_raw_audio_handler )

# 2. Once the speech recognizer has processed the WAV file, it passes
# the n-best list of speech hypotheses to the dialogue manager, save