Page 1068 - 3-2
P. 1068
내가 헬로우" ~" 라고 말하니 위처럼 찍혔다.
현재 소스 코드상에는 언어는 영어로 되어있고 딱 한 번만 인식 한다.
현재 소스 코드상에는 언어는 영어로 되어있고 딱 한 번만 인식 한다.
6) 음성인식 한국어로 변경 및 계속 인식하기
우선 한글 버전으로 변환하려면 speech_streaming.py 파일을을 수정을 한다.
def request_stream(stop_audio, channels=CHANNELS, rate=RATE, chunk=CHUNK):
recognition_config = cloud_speech.RecognitionConfig(
# There are a bunch of config options you can specify. See
# https://goo.gl/A6xv5G for the full list.
encoding='LINEAR16', # raw 16-bit signed LE samples
sample_rate=rate, # the rate in hertz
# See
# https://g.co/cloud/speech/docs/best-practices#language_support
# for a list of supported languages.
language_code='en-US', # a BCP-47 language tag
)
위의 코드에서 language_code='en-US' 를 language_code='ko-KR' 로 바꿔주면 된다.
그리고 계속해서 인식을 하려면 바로 아래에서
streaming_config = cloud_speech.StreamingRecognitionConfig(
config=recognition_config,
# Note that setting interim_results to True means that you'll likely
# get multiple results for the same bit of audio, as the system
# re-interprets audio in the context of subsequent audio. However, this
# will give us quick results without having to tell the server when to
# finalize a piece of audio.
interim_results=True, single_utterance=True
)
single_utterance=True 를 single_utterance=False 로 바꿔주면 계속 인식을 시도한다.
이렇게 해서 테스트를 해보면
텍스트가 숫자로 나온다.
이것은 8 진수 UTF-8 로 표기된 것이다.
- 1068 -