音声から音声への翻訳機能は、Live API を使用して、異なる言語を話す個人とシステム間の会話を可能にします。具体的には、ある言語の音声を含む音声ストリームを処理し、別の言語での翻訳をリアルタイムでストリーミングします。
ターンベースの会話をサポートする他の Live API 機能とは異なり、音声から音声への翻訳では、音声入力が継続的に処理され、次の出力が利用可能になるとストリーミングされます。
- 音声文字変換: 入力音声ストリームから認識された原文言語のテキスト。
- 翻訳: ターゲット言語に翻訳されたテキスト。
- 合成音声: ターゲット言語で読み上げられた翻訳テキストの音声ストリーム。
サポートされているモデル
音声から音声への翻訳には、次のモデルを使用できます。
| モデル バージョン | 可用性レベル |
|---|---|
gemini-2.5-flash-s2st-11-2025-exp |
公開試験運用版 |
入力音声の要件
音声から音声への翻訳は音声入力のみをサポートしています。サポートされている音声形式、コーデック、サンプルレートなどの仕様については、サポートされている音声形式をご覧ください。
音声翻訳を使用する
音声から音声への翻訳を使用するには、次のコード例をご覧ください。
Python
# Set language_code to your desired language. speech_config = SpeechConfig(language_code="cmn") config = LiveConnectConfig( response_modalities=["AUDIO"], speech_config=speech_config, input_audio_transcription=input_transcription, output_audio_transcription=output_transcription, )
Python
# Set model generation_config CONFIG = {"response_modalities": ["AUDIO"], "speech_config": {"language_code": cmn}} headers = { "Content-Type": "application/json", "Authorization": f"Bearer {bearer_token[0]}", } async def main() -> None: # Connect to the server async with connect(SERVICE_URL, additional_headers=headers) as ws: # Set up the session async def setup() -> None: await ws.send( json.dumps( { "setup": { "model": "gemini-2.5-flash-s2st-11-2025-exp", "generation_config": CONFIG, "input_audio_transcription": {}, "output_audio_transcription": {} } } ) ) # Receive setup response raw_response = await ws.recv(decode=False) setup_response = json.loads(raw_response.decode("ascii")) print(f"Connected: {setup_response}") return
お支払い
音声翻訳は試験運用版の機能であるため、使用しても料金は発生しません。
料金と請求の詳細については、Vertex AI の料金をご覧ください。