

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# StartSpeechSynthesisStream
<a name="API_StartSpeechSynthesisStream"></a>

透過雙向串流連線合成 UTF-8 輸入、純文字或 SSML。在 HTTP/2 標頭中指定合成參數、在輸入串流上以事件形式遞增傳送文字，並在可用時接收合成音訊。

此操作做為 的雙向對等項目`SynthesizeSpeech`：
+  [SynthesizeSpeech](https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html) 

## 請求語法
<a name="API_StartSpeechSynthesisStream_RequestSyntax"></a>

```
POST /v1/synthesisStream HTTP/1.1
x-amzn-Engine: {{Engine}}
x-amzn-LanguageCode: {{LanguageCode}}
x-amzn-LexiconNames: {{LexiconNames}}
x-amzn-OutputFormat: {{OutputFormat}}
x-amzn-SampleRate: {{SampleRate}}
x-amzn-VoiceId: {{VoiceId}}
Content-type: application/json

{
   "CloseStreamEvent": { 
   },
   "TextEvent": { 
      "FlushStreamConfiguration": { 
         "Force": {{boolean}}
      },
      "Text": "{{string}}",
      "TextType": "{{string}}"
   }
}
```

## URI 請求參數
<a name="API_StartSpeechSynthesisStream_RequestParameters"></a>

請求會使用下列 URI 參數。

 ** [Engine](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-Engine"></a>
指定 Amazon Polly 在處理語音合成的輸入文字時要使用的引擎。目前僅支援 `generative`引擎。如果您指定所選引擎不支援的語音，Amazon Polly 會傳回錯誤。  
有效值:`standard | neural | long-form | generative`   
必要：是

 ** [LanguageCode](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-LanguageCode"></a>
選用參數，可設定語音合成請求的語言代碼。只有在使用雙語語音時，才指定此參數。如果使用雙語語音且未指定語言代碼，Amazon Polly 會使用雙語語音的預設語言。  
有效值:`arb | cmn-CN | cy-GB | da-DK | de-DE | en-AU | en-GB | en-GB-WLS | en-IN | en-US | es-ES | es-MX | es-US | fr-CA | fr-FR | is-IS | it-IT | ja-JP | hi-IN | ko-KR | nb-NO | nl-NL | pl-PL | pt-BR | pt-PT | ro-RO | ru-RU | sv-SE | tr-TR | en-NZ | en-ZA | ca-ES | de-AT | yue-CN | ar-AE | fi-FI | en-IE | nl-BE | fr-BE | cs-CZ | de-CH | en-SG` 

 ** [LexiconNames](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-LexiconNames"></a>
要在合成期間套用之服務的一或多個發音語彙的名稱。Amazon Polly 才會套用語彙。  
陣列成員：最多 5 個項目。  
模式：`[0-9A-Za-z]{1,20}`

 ** [OutputFormat](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-OutputFormat"></a>
合成語音的音訊格式。目前，Amazon Polly 不支援 JSON 語音標記。  
有效值:`json | mp3 | ogg_opus | ogg_vorbis | pcm | mulaw | alaw`   
必要：是

 ** [SampleRate](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-SampleRate"></a>
音訊頻率，以 Hz 指定。

 ** [VoiceId](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-VoiceId"></a>
用於合成的語音。若要取得可用語音 IDs的清單，請使用 [DescribeVoices](https://docs.aws.amazon.com/polly/latest/dg/API_DescribeVoices.html) 操作。  
有效值:`Aditi | Amy | Astrid | Bianca | Brian | Camila | Carla | Carmen | Celine | Chantal | Conchita | Cristiano | Dora | Emma | Enrique | Ewa | Filiz | Gabrielle | Geraint | Giorgio | Gwyneth | Hans | Ines | Ivy | Jacek | Jan | Joanna | Joey | Justin | Karl | Kendra | Kevin | Kimberly | Lea | Liv | Lotte | Lucia | Lupe | Mads | Maja | Marlene | Mathieu | Matthew | Maxim | Mia | Miguel | Mizuki | Naja | Nicole | Olivia | Penelope | Raveena | Ricardo | Ruben | Russell | Salli | Seoyeon | Takumi | Tatyana | Vicki | Vitoria | Zeina | Zhiyu | Aria | Ayanda | Arlet | Hannah | Arthur | Daniel | Liam | Pedro | Kajal | Hiujin | Laura | Elin | Ida | Suvi | Ola | Hala | Andres | Sergio | Remi | Adriano | Thiago | Ruth | Stephen | Kazuha | Tomoko | Niamh | Sofie | Lisa | Isabelle | Zayd | Danielle | Gregory | Burcu | Jitka | Sabrina | Jasmine | Jihye | Ambre | Beatrice | Florian | Lennart | Lorenzo | Tiffany`   
必要：是

## 請求主體
<a name="API_StartSpeechSynthesisStream_RequestBody"></a>

請求接受採用 JSON 格式的下列資料。

 ** [CloseStreamEvent](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-CloseStreamEvent"></a>
指出輸入串流結束的事件。  
類型：[CloseStreamEvent](API_CloseStreamEvent.md) 物件  
必要：否

 ** [TextEvent](#API_StartSpeechSynthesisStream_RequestSyntax) **   <a name="polly-StartSpeechSynthesisStream-request-TextEvent"></a>
包含要合成內容的文字事件。  
類型：[TextEvent](API_TextEvent.md) 物件  
必要：否

## 回應語法
<a name="API_StartSpeechSynthesisStream_ResponseSyntax"></a>

```
HTTP/1.1 200
Content-type: application/json

{
   "AudioEvent": { 
      "AudioChunk": blob
   },
   "ServiceFailureException": { 
   },
   "ServiceQuotaExceededException": { 
   },
   "StreamClosedEvent": { 
      "RequestCharacters": number
   },
   "ThrottlingException": { 
   },
   "ValidationException": { 
   }
}
```

## 回應元素
<a name="API_StartSpeechSynthesisStream_ResponseElements"></a>

如果動作成功，則服務傳回 HTTP 200 回應。

服務會傳回下列 JSON 格式的資料。

 ** [AudioEvent](#API_StartSpeechSynthesisStream_ResponseSyntax) **   <a name="polly-StartSpeechSynthesisStream-response-AudioEvent"></a>
包含合成語音的音訊事件。  
類型：[AudioEvent](API_AudioEvent.md) 物件

 ** [ServiceFailureException](#API_StartSpeechSynthesisStream_ResponseSyntax) **   <a name="polly-StartSpeechSynthesisStream-response-ServiceFailureException"></a>
不明條件導致服務失敗。  
類型：例外狀況  
HTTP 狀態碼：500

 ** [ServiceQuotaExceededException](#API_StartSpeechSynthesisStream_ResponseSyntax) **   <a name="polly-StartSpeechSynthesisStream-response-ServiceQuotaExceededException"></a>
超出表示服務配額的例外狀況。  
類型：例外狀況  
HTTP 狀態碼：402

 ** [StreamClosedEvent](#API_StartSpeechSynthesisStream_ResponseSyntax) **   <a name="polly-StartSpeechSynthesisStream-response-StreamClosedEvent"></a>
具有摘要資訊的事件，表示串流已關閉。  
類型：[StreamClosedEvent](API_StreamClosedEvent.md) 物件

 ** [ThrottlingException](#API_StartSpeechSynthesisStream_ResponseSyntax) **   <a name="polly-StartSpeechSynthesisStream-response-ThrottlingException"></a>
表示請求已調節的例外狀況。  
類型：例外狀況  
HTTP 狀態碼：400

 ** [ValidationException](#API_StartSpeechSynthesisStream_ResponseSyntax) **   <a name="polly-StartSpeechSynthesisStream-response-ValidationException"></a>
表示輸入驗證失敗的例外狀況。  
類型：例外狀況  
HTTP 狀態碼：400

## 錯誤
<a name="API_StartSpeechSynthesisStream_Errors"></a>

 ** ServiceFailureException **   
不明條件導致服務失敗。  
HTTP 狀態碼：500

 ** ServiceQuotaExceededException **   
請求會導致超過服務配額。    
 ** quotaCode **   
識別特定配額的配額代碼。  
 ** serviceCode **   
識別原始服務的服務代碼。
HTTP 狀態碼：402

 ** ThrottlingException **   
請求因請求限流而遭拒。    
 ** throttlingReasons **   
說明請求受到限流原因的原因清單。
HTTP 狀態碼：400

 ** ValidationException **   
輸入無法滿足 服務指定的限制條件。    
 ** fields **   
導致驗證錯誤的欄位。  
 ** reason **   
請求驗證失敗的原因。
HTTP 狀態碼：400

## 另請參閱
<a name="API_StartSpeechSynthesisStream_SeeAlso"></a>

如需在其中一種語言特定 AWS SDKs中使用此 API 的詳細資訊，請參閱下列內容：
+  [AWS 命令列界面 V2](https://docs.aws.amazon.com/goto/cli2/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 .NET V4 的 SDK](https://docs.aws.amazon.com/goto/DotNetSDKV4/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 C\+\+ 的 SDK](https://docs.aws.amazon.com/goto/SdkForCpp/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 Go 的 SDK v2](https://docs.aws.amazon.com/goto/SdkForGoV2/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 Java V2 的 SDK](https://docs.aws.amazon.com/goto/SdkForJavaV2/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 JavaScript V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 Kotlin 的 SDK](https://docs.aws.amazon.com/goto/SdkForKotlin/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 PHP V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForPHPV3/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 Python 的 SDK](https://docs.aws.amazon.com/goto/boto3/polly-2016-06-10/StartSpeechSynthesisStream) 
+  [AWS 適用於 Ruby V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForRubyV3/polly-2016-06-10/StartSpeechSynthesisStream) 