Page 325 - 3-2
P. 325
global musicVol
global flag_five
for resp in recognize_stream:
if resp.error.code != code_pb2.OK:
print("\n 음성인식 시간이 초과되었습니다.")
raise RuntimeError('Server error: ' + resp.error.message)
speak_fail = pygame.image.load('speak_fail.png')
screen.blit(speak_fail, (0, 0))
pygame.display.flip()
if not resp.results:
continue
# Display the top transcription
result = resp.results[0]
transcript = result.alternatives[0].transcript
# Display interim results, but with a carriage return at the end of the
# line, so subsequent lines will overwrite them.
#
# If the previous result was longer than this one, we need to print
# some extra spaces to overwrite the previous result
if re.search(u' 안녕', transcript, re.I):
print('say: 안녕하세요')
result=''
if re.search(u' 인천국제공항', transcript, re.I) or re.search(u' 국제공항', transcript, re.I):
print('say: 인천국제공항')
result=''
return 0
if re.search(u' 공항화물청사', transcript, re.I) or re.search(u' 화물청사', transcript, re.I):
print('say: 공항화물청사')
result=''
return 1
if re.search(u' 운서', transcript, re.I) or re.search(u' 은서', transcript, re.I) or re.search(u' 문
서', transcript, re.I):
print('say: say: 운서')
result=''
return 2
- 325 -