2017-04-04 12 views
1

Googleのスピーチに関するテキストをAPIについて知りたい。 Googleのクラウド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が提供する言語コードです。

答えて

関連する問題