Page 502 - 3-2
P. 502

def listen_print_loop(recognize_stream):

                """Iterates through server responses and prints them.
                The recognize_stream passed is a generator that will block until a response

                is provided by the server. When the transcription response comes, print it.
                In this case, responses are provided for interim results as well. If the

                response is an interim one, print a line feed at the end of it, to allow
                the next result to overwrite it, until the response is a final one. For the

                final one, print a newline to preserve the finalized transcription.
                """

                global musicFiles
                global musicNum

                global MAX_musicNum
                global flag_zero

                global musicVol
                global flag_five

                song_flag = 0
                mirror_mode = 0

                cnt = 0 # 횟수를 세기위한 변수
                talk = 0

                no_talk = pygame.image.load('Q2.png')
                no_talk = pygame.transform.scale(no_talk, (900, 1100))



                for resp in recognize_stream:

                            pygame.init()
                            # if resp.error.code != code_pb2.OK:

                            #    print("\n 음성인식 시간이 초과되었습니다.")
                            #    raise RuntimeError('Server error: ' + resp.error.message)



                            if not resp.results:

                                            sys.stdout.write('\r\n')
                                            continue



                            # Display the top transcription

                            result = resp.results[0]
                            transcript = result.alternatives[0].transcript



                                                         - 502 -
   497   498   499   500   501   502   503   504   505   506   507