#NEWLINE# def handle_online_request( self , request ) : #NEWLINE# #INDENT# hypotheses = [ ] #NEWLINE# for ( original_pcm , resampled_pcm ) in self . audio . chunks ( request . body , request . frame_rate ) : #NEWLINE# #INDENT# ( vad , change , original_pcm , resampled_pcm ) = self . vad . decide ( original_pcm , resampled_pcm ) #NEWLINE# current_chunk_id = self . current_chunk_id #NEWLINE# if vad : #NEWLINE# #INDENT# is_final = False #NEWLINE# hypothesis = [ self . asr . recognize_chunk ( resampled_pcm ) ] #NEWLINE# self . saver . add_pcm ( original_pcm ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# is_final = False #NEWLINE# hypothesis = [ ( 1.0 , '' ) ] #NEWLINE# #UNINDENT# if ( ( change == 'non-speech' ) or ( request . has_next == False ) or ( request . new_lm != '' ) ) : #NEWLINE# #INDENT# is_final = True #NEWLINE# hypothesis = self . asr . get_final_hypothesis ( ) #NEWLINE# self . asr . reset ( ) #NEWLINE# self . saver . final_hypothesis ( current_chunk_id , hypothesis ) #NEWLINE# self . current_chunk_id = self . id_generator ( ) #NEWLINE# #UNINDENT# if request . new_lm : #NEWLINE# #INDENT# self . asr . change_lm ( request . new_lm ) #NEWLINE# #UNINDENT# hypotheses . append ( ( current_chunk_id , is_final , hypothesis ) ) #NEWLINE# #UNINDENT# self . send_hypotheses ( hypotheses ) #NEWLINE# if request . has_next : #NEWLINE# #INDENT# self . heartbeat . send ( 'WORKING' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . end_recognition ( ) #NEWLINE# self . heartbeat . send ( 'FINISHED' )