start_speech_synthesis_stream
¶
start_speech_synthesis_stream(
engine: Engine,
output_format: OutputFormat,
voice_id: VoiceId,
*,
config_overrides: Optional[PollyClientConfig] = None,
language_code: Optional[LanguageCode] = None,
lexicon_names: Optional[LexiconNameList] = None,
sample_rate: Optional[SampleRate] = None,
action_stream: Optional[
Iterator[_StartSpeechSynthesisStreamActionStream]
| _StartSpeechSynthesisStreamActionStream
] = None,
) -> Generator[StartSpeechSynthesisStreamOutput]
Synthesizes UTF-8 input, plain text, or SSML over a bidirectional streaming connection. Specify synthesis parameters in HTTP/2 headers, send text incrementally as events on the input stream, and receive synthesized audio as it becomes available.
This operation serves as a bidirectional counterpart to SynthesizeSpeech:
To use a custom voice, specify its ID in VoiceId. The voice must be in active status. If the voice is in pending or failed status, the request fails with ConflictException. If no custom voice with the specified ID exists in your account and Region, the request fails with ResourceNotFoundException. If the custom voice uses a customer managed key, you need kms:Decrypt permission on the key. If you disabled the key or scheduled it for deletion, the request fails with ValidationException. If you don't have permission to use the key, the request fails with AccessDeniedException. If Amazon Web Services KMS throttles Amazon Polly's request to use the key, the request fails with ThrottlingException.
Parameters:
-
engine(Engine) –Specifies the engine for Amazon Polly to use when processing input text for speech synthesis. Currently, only the
generativeengine is supported. If you specify a voice that the selected engine doesn't support, Amazon Polly returns an error. -
language_code(Optional[LanguageCode], default:None) –An optional parameter that sets the language code for the speech synthesis request. Specify this parameter only when using a bilingual voice. If a bilingual voice is used and no language code is specified, Amazon Polly uses the default language of the bilingual voice.
-
lexicon_names(Optional[LexiconNameList], default:None) –The names of one or more pronunciation lexicons for the service to apply during synthesis. Amazon Polly applies lexicons only when the lexicon language matches the voice language.
-
output_format(OutputFormat) –The audio format for the synthesized speech. Currently, Amazon Polly does not support JSON speech marks.
-
sample_rate(Optional[SampleRate], default:None) –The audio frequency, specified in Hz.
-
voice_id(VoiceId) –The voice ID to use for the synthesis. To get a list of available voice IDs, use the DescribeVoices operation. To use a custom voice, specify the voice ID that
CreateVoicereturned, for example,vc-9a8fa85dd3. You can't specify the ARN of a voice. -
action_stream(Optional[Iterator[_StartSpeechSynthesisStreamActionStream] | _StartSpeechSynthesisStreamActionStream], default:None) –The input event stream that contains text events and stream control events.
Raises:
-
ConflictException–The request conflicts with the current state of the resource. For a custom voice, the voice isn't in the status that the operation requires. Check the status with
GetVoice, and then try again. -
ResourceNotFoundException–Amazon Polly can't find the specified resource. Verify that the resource exists in the Amazon Web Services account and Region of the request and that its ARN or ID is spelled correctly, and then try again.
-
ServiceFailureException–An unknown condition has caused a service failure.
-
ServiceQuotaExceededException–The request would cause a service quota to be exceeded.
-
ThrottlingException–The request was denied because of request throttling.
-
ValidationException–The input fails to satisfy the constraints specified by the service.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_polly/_services/polly.py
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 | |