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:
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 to use in synthesis. To get a list of available voice IDs, use the DescribeVoices operation.
-
action_stream(Optional[Iterator[_StartSpeechSynthesisStreamActionStream] | _StartSpeechSynthesisStreamActionStream], default:None) –The input event stream that contains text events and stream control events.
Raises:
-
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
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | |