|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | from typing import Dict, Union, Iterable |
6 | | -from typing_extensions import Literal, Required, Annotated, TypedDict |
| 6 | +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict |
7 | 7 |
|
8 | 8 | from .._types import SequenceNotStr |
9 | 9 | from .._utils import PropertyInfo |
|
15 | 15 | from .stream_bidirectional_mode import StreamBidirectionalMode |
16 | 16 | from .stream_bidirectional_codec import StreamBidirectionalCodec |
17 | 17 | from .call_assistant_request_param import CallAssistantRequestParam |
| 18 | +from .calls.aws_voice_settings_param import AwsVoiceSettingsParam |
| 19 | +from .shared_params.xai_voice_settings import XaiVoiceSettings |
18 | 20 | from .stream_bidirectional_target_legs import StreamBidirectionalTargetLegs |
| 21 | +from .calls.telnyx_voice_settings_param import TelnyxVoiceSettingsParam |
| 22 | +from .shared_params.rime_voice_settings import RimeVoiceSettings |
| 23 | +from .shared_params.azure_voice_settings import AzureVoiceSettings |
19 | 24 | from .stream_bidirectional_sampling_rate import StreamBidirectionalSamplingRate |
| 25 | +from .shared_params.minimax_voice_settings import MinimaxVoiceSettings |
| 26 | +from .shared_params.resemble_voice_settings import ResembleVoiceSettings |
| 27 | +from .calls.eleven_labs_voice_settings_param import ElevenLabsVoiceSettingsParam |
20 | 28 | from .calls.transcription_start_request_param import TranscriptionStartRequestParam |
21 | 29 |
|
22 | 30 | __all__ = [ |
23 | 31 | "CallDialParams", |
24 | 32 | "AnsweringMachineDetectionConfig", |
25 | 33 | "ConferenceConfig", |
| 34 | + "ConversationRelayConfig", |
| 35 | + "ConversationRelayConfigInterruptionSettings", |
| 36 | + "ConversationRelayConfigLanguage", |
| 37 | + "ConversationRelayConfigLanguageVoiceSettings", |
| 38 | + "ConversationRelayConfigLanguageVoiceSettingsInworldVoiceSettings", |
| 39 | + "ConversationRelayConfigVoiceSettings", |
| 40 | + "ConversationRelayConfigVoiceSettingsInworldVoiceSettings", |
26 | 41 | "DeepfakeDetection", |
27 | 42 | "WebhookRetriesPolicies", |
28 | 43 | ] |
@@ -134,6 +149,16 @@ class CallDialParams(TypedDict, total=False): |
134 | 149 | conference_config: ConferenceConfig |
135 | 150 | """Optional configuration parameters to dial new participant into a conference.""" |
136 | 151 |
|
| 152 | + conversation_relay_config: ConversationRelayConfig |
| 153 | + """ |
| 154 | + Starts a Conversation Relay session automatically when the answered/dialed call |
| 155 | + is answered. This embedded shape is supported on `answer` and `dial`. It uses |
| 156 | + public field names (`url`, `dtmf_detection`, `greeting`, `voice`, `language`, |
| 157 | + etc.) and maps them to the underlying Conversation Relay action. `client_state`, |
| 158 | + `tts_language`, and `transcription_language` inside this object are ignored; use |
| 159 | + the parent command's `client_state` and `command_id` fields instead. |
| 160 | + """ |
| 161 | + |
137 | 162 | custom_headers: Iterable[CustomSipHeaderParam] |
138 | 163 | """Custom headers to be added to the SIP INVITE.""" |
139 | 164 |
|
@@ -542,6 +567,242 @@ class ConferenceConfig(TypedDict, total=False): |
542 | 567 | """ |
543 | 568 |
|
544 | 569 |
|
| 570 | +class ConversationRelayConfigInterruptionSettings(TypedDict, total=False): |
| 571 | + """Settings for handling caller interruptions during Conversation Relay speech.""" |
| 572 | + |
| 573 | + enable: bool |
| 574 | + """Legacy boolean form. |
| 575 | +
|
| 576 | + `true` is equivalent to `interruptible=any`; `false` is equivalent to |
| 577 | + `interruptible=none`. |
| 578 | + """ |
| 579 | + |
| 580 | + interruptible: Literal["none", "any", "speech", "dtmf"] |
| 581 | + """Controls when caller input can interrupt assistant speech. |
| 582 | +
|
| 583 | + `any` allows speech or DTMF interruptions; `none` disables interruptions; |
| 584 | + `speech` allows speech only; `dtmf` allows DTMF only. |
| 585 | + """ |
| 586 | + |
| 587 | + interruptible_greeting: Literal["none", "any", "speech", "dtmf"] |
| 588 | + """Controls when caller input can interrupt assistant speech. |
| 589 | +
|
| 590 | + `any` allows speech or DTMF interruptions; `none` disables interruptions; |
| 591 | + `speech` allows speech only; `dtmf` allows DTMF only. |
| 592 | + """ |
| 593 | + |
| 594 | + welcome_greeting_interruptible: Literal["none", "any", "speech", "dtmf"] |
| 595 | + """Controls when caller input can interrupt assistant speech. |
| 596 | +
|
| 597 | + `any` allows speech or DTMF interruptions; `none` disables interruptions; |
| 598 | + `speech` allows speech only; `dtmf` allows DTMF only. |
| 599 | + """ |
| 600 | + |
| 601 | + |
| 602 | +class ConversationRelayConfigLanguageVoiceSettingsInworldVoiceSettings(TypedDict, total=False): |
| 603 | + type: Required[Literal["inworld"]] |
| 604 | + """Voice settings provider type""" |
| 605 | + |
| 606 | + |
| 607 | +ConversationRelayConfigLanguageVoiceSettings: TypeAlias = Union[ |
| 608 | + ElevenLabsVoiceSettingsParam, |
| 609 | + TelnyxVoiceSettingsParam, |
| 610 | + AwsVoiceSettingsParam, |
| 611 | + MinimaxVoiceSettings, |
| 612 | + AzureVoiceSettings, |
| 613 | + RimeVoiceSettings, |
| 614 | + ResembleVoiceSettings, |
| 615 | + ConversationRelayConfigLanguageVoiceSettingsInworldVoiceSettings, |
| 616 | + XaiVoiceSettings, |
| 617 | +] |
| 618 | + |
| 619 | + |
| 620 | +class ConversationRelayConfigLanguage(TypedDict, total=False): |
| 621 | + """Language-specific TTS and transcription settings for Conversation Relay.""" |
| 622 | + |
| 623 | + language: Required[str] |
| 624 | + """BCP 47 language tag for this language configuration.""" |
| 625 | + |
| 626 | + speech_model: str |
| 627 | + """Conversation Relay speech model. |
| 628 | +
|
| 629 | + Prefer `transcription_engine_config.transcription_model` when configuring |
| 630 | + speech-to-text. |
| 631 | + """ |
| 632 | + |
| 633 | + transcription_engine: Literal[ |
| 634 | + "Google", "Telnyx", "Deepgram", "Azure", "xAI", "AssemblyAI", "Speechmatics", "Soniox", "A", "B" |
| 635 | + ] |
| 636 | + """Engine to use for speech recognition. |
| 637 | +
|
| 638 | + Legacy values `A` - `Google`, `B` - `Telnyx` are supported for backward |
| 639 | + compatibility. When provided in a Conversation Relay language entry, Telnyx |
| 640 | + derives `transcription_provider` and `speech_model` for that language. |
| 641 | + """ |
| 642 | + |
| 643 | + transcription_engine_config: Dict[str, object] |
| 644 | + """Engine-specific transcription settings for Conversation Relay. |
| 645 | +
|
| 646 | + This accepts the same provider-specific options used by the Call Transcription |
| 647 | + Start command, such as `transcription_model`, without requiring the engine |
| 648 | + discriminator to be repeated inside this object. |
| 649 | + """ |
| 650 | + |
| 651 | + transcription_provider: str |
| 652 | + """Conversation Relay transcription provider name. |
| 653 | +
|
| 654 | + Prefer `transcription_engine` when configuring speech-to-text. |
| 655 | + """ |
| 656 | + |
| 657 | + tts_provider: str |
| 658 | + """Text-to-speech provider for this language. |
| 659 | +
|
| 660 | + If omitted and `voice` is provided, Telnyx derives the provider from the voice |
| 661 | + identifier. |
| 662 | + """ |
| 663 | + |
| 664 | + voice: str |
| 665 | + """Voice identifier for this language.""" |
| 666 | + |
| 667 | + voice_settings: ConversationRelayConfigLanguageVoiceSettings |
| 668 | + """The settings associated with the voice selected""" |
| 669 | + |
| 670 | + |
| 671 | +class ConversationRelayConfigVoiceSettingsInworldVoiceSettings(TypedDict, total=False): |
| 672 | + type: Required[Literal["inworld"]] |
| 673 | + """Voice settings provider type""" |
| 674 | + |
| 675 | + |
| 676 | +ConversationRelayConfigVoiceSettings: TypeAlias = Union[ |
| 677 | + ElevenLabsVoiceSettingsParam, |
| 678 | + TelnyxVoiceSettingsParam, |
| 679 | + AwsVoiceSettingsParam, |
| 680 | + MinimaxVoiceSettings, |
| 681 | + AzureVoiceSettings, |
| 682 | + RimeVoiceSettings, |
| 683 | + ResembleVoiceSettings, |
| 684 | + ConversationRelayConfigVoiceSettingsInworldVoiceSettings, |
| 685 | + XaiVoiceSettings, |
| 686 | +] |
| 687 | + |
| 688 | + |
| 689 | +class ConversationRelayConfig(TypedDict, total=False): |
| 690 | + """ |
| 691 | + Starts a Conversation Relay session automatically when the answered/dialed call is answered. This embedded shape is supported on `answer` and `dial`. It uses public field names (`url`, `dtmf_detection`, `greeting`, `voice`, `language`, etc.) and maps them to the underlying Conversation Relay action. `client_state`, `tts_language`, and `transcription_language` inside this object are ignored; use the parent command's `client_state` and `command_id` fields instead. |
| 692 | + """ |
| 693 | + |
| 694 | + url: Required[str] |
| 695 | + """WebSocket URL for your Conversation Relay server. |
| 696 | +
|
| 697 | + Must start with `ws://` or `wss://`. |
| 698 | + """ |
| 699 | + |
| 700 | + custom_parameters: Dict[str, object] |
| 701 | + """ |
| 702 | + Custom key-value parameters forwarded to the relay session as assistant dynamic |
| 703 | + variables. |
| 704 | + """ |
| 705 | + |
| 706 | + dtmf_detection: bool |
| 707 | + """Enable DTMF detection for the relay session.""" |
| 708 | + |
| 709 | + greeting: str |
| 710 | + """Text played when the relay session starts.""" |
| 711 | + |
| 712 | + interruptible: Literal["none", "any", "speech", "dtmf"] |
| 713 | + """Controls when caller input can interrupt assistant speech. |
| 714 | +
|
| 715 | + `any` allows speech or DTMF interruptions; `none` disables interruptions; |
| 716 | + `speech` allows speech only; `dtmf` allows DTMF only. |
| 717 | + """ |
| 718 | + |
| 719 | + interruptible_greeting: Literal["none", "any", "speech", "dtmf"] |
| 720 | + """Controls when caller input can interrupt assistant speech. |
| 721 | +
|
| 722 | + `any` allows speech or DTMF interruptions; `none` disables interruptions; |
| 723 | + `speech` allows speech only; `dtmf` allows DTMF only. |
| 724 | + """ |
| 725 | + |
| 726 | + interruption_settings: ConversationRelayConfigInterruptionSettings |
| 727 | + """Settings for handling caller interruptions during Conversation Relay speech.""" |
| 728 | + |
| 729 | + language: str |
| 730 | + """Default language for both text-to-speech and speech recognition.""" |
| 731 | + |
| 732 | + languages: Iterable[ConversationRelayConfigLanguage] |
| 733 | + """Per-language TTS and transcription settings.""" |
| 734 | + |
| 735 | + provider: str |
| 736 | + """Structured voice provider. |
| 737 | +
|
| 738 | + Must be supplied together with `structured_provider`. |
| 739 | + """ |
| 740 | + |
| 741 | + structured_provider: Dict[str, object] |
| 742 | + """Provider-specific structured voice settings. |
| 743 | +
|
| 744 | + Must be supplied together with `provider`; Telnyx sends the value as the nested |
| 745 | + provider configuration for Conversation Relay. |
| 746 | + """ |
| 747 | + |
| 748 | + transcription_engine: Literal[ |
| 749 | + "Google", "Telnyx", "Deepgram", "Azure", "xAI", "AssemblyAI", "Speechmatics", "Soniox", "A", "B" |
| 750 | + ] |
| 751 | + """Engine to use for speech recognition. |
| 752 | +
|
| 753 | + Legacy values `A` - `Google`, `B` - `Telnyx` are supported for backward |
| 754 | + compatibility. For Conversation Relay, use this field with |
| 755 | + `transcription_engine_config`; the `transcription` object is not supported. |
| 756 | + """ |
| 757 | + |
| 758 | + transcription_engine_config: Dict[str, object] |
| 759 | + """Engine-specific transcription settings for Conversation Relay. |
| 760 | +
|
| 761 | + This accepts the same provider-specific options used by the Call Transcription |
| 762 | + Start command, such as `transcription_model`, without requiring the engine |
| 763 | + discriminator to be repeated inside this object. |
| 764 | + """ |
| 765 | + |
| 766 | + tts_provider: str |
| 767 | + """Text-to-speech provider. |
| 768 | +
|
| 769 | + If omitted, Telnyx derives it from `voice` or `provider`. |
| 770 | + """ |
| 771 | + |
| 772 | + voice: str |
| 773 | + """The voice to be used by the voice assistant. |
| 774 | +
|
| 775 | + Currently we support ElevenLabs, Telnyx and AWS voices. |
| 776 | +
|
| 777 | + **Supported Providers:** |
| 778 | +
|
| 779 | + - **AWS:** Use `AWS.Polly.<VoiceId>` (e.g., `AWS.Polly.Joanna`). For neural |
| 780 | + voices, which provide more realistic, human-like speech, append `-Neural` to |
| 781 | + the `VoiceId` (e.g., `AWS.Polly.Joanna-Neural`). Check the |
| 782 | + [available voices](https://docs.aws.amazon.com/polly/latest/dg/available-voices.html) |
| 783 | + for compatibility. |
| 784 | + - **Azure:** Use `Azure.<VoiceId>. (e.g. Azure.en-CA-ClaraNeural, |
| 785 | + Azure.en-CA-LiamNeural, Azure.en-US-BrianMultilingualNeural, |
| 786 | + Azure.en-US-Ava:DragonHDLatestNeural. For a complete list of voices, go to |
| 787 | + [Azure Voice Gallery](https://speech.microsoft.com/portal/voicegallery).) |
| 788 | + - **ElevenLabs:** Use `ElevenLabs.<ModelId>.<VoiceId>` (e.g., |
| 789 | + `ElevenLabs.BaseModel.John`). The `ModelId` part is optional. To use |
| 790 | + ElevenLabs, you must provide your ElevenLabs API key as an integration secret |
| 791 | + under `"voice_settings": {"api_key_ref": "<secret_id>"}`. See |
| 792 | + [integration secrets documentation](https://developers.telnyx.com/api/secrets-manager/integration-secrets/create-integration-secret) |
| 793 | + for details. Check |
| 794 | + [available voices](https://elevenlabs.io/docs/api-reference/get-voices). |
| 795 | + - **Telnyx:** Use `Telnyx.<model_id>.<voice_id>` |
| 796 | + - **Inworld:** Use `Inworld.<ModelId>.<VoiceId>` (e.g., `Inworld.Mini.Loretta`, |
| 797 | + `Inworld.Max.Oliver`). Supported models: `Mini`, `Max`. |
| 798 | + - **xAI:** Use `xAI.<VoiceId>` (e.g., `xAI.eve`). Available voices: `eve`, |
| 799 | + `ara`, `rex`, `sal`, `leo`. |
| 800 | + """ |
| 801 | + |
| 802 | + voice_settings: ConversationRelayConfigVoiceSettings |
| 803 | + """The settings associated with the voice selected""" |
| 804 | + |
| 805 | + |
545 | 806 | class DeepfakeDetection(TypedDict, total=False): |
546 | 807 | """Enables deepfake detection on the call. |
547 | 808 |
|
|
0 commit comments