1
我想了解Google語音文本API。我嘗試了谷歌雲提供的示例代碼API。如何在Google Speech API中設置語言Python客戶端
這是我的代碼:
import io
import os
# Imports the Google Cloud client library
from google.cloud import speech
# Instantiates a client
speech_client = speech.Client()
# The name of the audio file to transcribe
file_name = os.path.join(
os.path.dirname(__file__),
'resources',
'audio.raw')
# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file:
content = audio_file.read()
audio_sample = speech_client.sample(
content,
source_uri=None,
encoding='LINEAR16',
sample_rate=16000)
# Detects speech in the audio file
alternatives = speech_client.speech_api.sync_recognize(audio_sample)
for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))
然後,我想知道我如何可以使用,而不是英語之外的語言。 有一件事我想用韓文識別,而不是英文。 那麼,請問,我應該如何將這段代碼放入韓文識別中? ko-kr是Google提供的語言代碼。