Page 335 - 3-2
P. 335

result=''
                            return 78


                    if  re.search(u' 인천논현',   transcript,  re.I)  or  re.search(u' 논현',  transcript,  re.I)  or
            re.search(u' 인천면', transcript, re.I):
                            print('say:  인천논현')
                            result=''
                            return 79


                    if (re.search(u' 종료', transcript, re.I) or re.search(u' 종묘',transcript, re.I) or re.search(u'  끝
            ',transcript, re.I) or re.search(u' 돌아가기', transcript, re.I) or re.search(u' 노라조',transcript, re.I) or
            re.search(u' 돌아',transcript, re.I) or re.search(u' 취소',transcript, re.I)):
                            print('say:  취소')
                            return 82
                            break


                    if (re.search(u' 수동', transcript, re.I)):
                            print('say:  수동')
                            return 83
                            break


                    print('say: ?')
                    sys.stdout.write(transcript + '\r\n')
                    sys.stdout.flush()
                    #time.sleep(1)


            def main_voice():
                global grpc
                service = cloud_speech_pb2.SpeechStub(
                    make_channel('speech.googleapis.com', 443))
                # For streaming audio from the microphone, there are three threads.
                # First, a thread that collects audio data as it comes in
                with record_audio(RATE, CHUNK) as buffered_audio_data:
                    # Second, a thread that sends requests with that data
                    requests = request_stream(buffered_audio_data, RATE)
                    # Third, a thread that listens for transcription responses
                    recognize_stream = service.StreamingRecognize(
                        requests, DEADLINE_SECS)


                    # Exit things cleanly on interrupt
                    signal.signal(signal.SIGINT, lambda *_: recognize_stream.cancel())


                    # Now, put the transcription responses to use.
                    try:
                        info = listen_print_loop(recognize_stream)


                                                         - 335 -
   330   331   332   333   334   335   336   337   338   339   340