示例#1
0
文件: test2.py 项目: wpli/dialog
import tbh_dialog_manager


# Start the GUI
# It needs to be on its own thread
gui_manager = tbh_audio_listener_gui.tbh_gui_manager()
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( dm.process_nbest_handler )

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

# Add handlers to the speech recognizer


al_thread = threading.Thread( target=gui_manager.audio_listener.run )
al_thread.start()
示例#2
0
## Load Skype contacts
skype_contacts_dict = tbh_skype_interface.load_skype_contacts( \
    'skype_contact_names_00.txt' )

# -------------------- #
#    INITIALIZATION    #
# -------------------- #
# ---- INITIALIZE THINGS ---- #
# Initialize the dialog manager
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' )