wxc_sdk.telephony.text_to_speech package

class wxc_sdk.telephony.text_to_speech.TtsUsageResponse(*, noOfApiCalls: int | None = None, maxAllowedApiCalls: int | None = None, usageResetTimestamp: datetime | None = None, **extra_data: Any)[source]

Bases: ApiModel

no_of_api_calls: int | None

The number of text-to-speech API calls made in the current time window.

max_allowed_api_calls: int | None

The maximum number of text-to-speech API calls allowed in the current time window.

usage_reset_timestamp: datetime | None

The timestamp when the usage counter will reset. It will be returned when reaching the maximum allowed API calls in the time window.

class wxc_sdk.telephony.text_to_speech.TtsStatusResponse(*, id: str | None = None, voice: str | None = None, text: str | None = None, languageCode: str | None = None, status: TtsStatusResponseStatus | None = None, promptUrl: str | None = None, kmsKeyUri: str | None = None, fileUri: str | None = None, errorMessage: str | None = None, **extra_data: Any)[source]

Bases: ApiModel

id: str | None

Unique identifier of the text-to-speech generation request.

voice: str | None

The voice ID used to generate the audio prompt.

text: str | None

The input text used to generate the audio prompt.

language_code: str | None

The language code used to generate the audio prompt.

status: TtsStatusResponseStatus | None

The status of the text-to-speech generation request.

prompt_url: str | None

A URL to download the encrypted audio prompt. Only available when status is SUCCESS.

kms_key_uri: str | None

The KMS key URI required to decrypt the prompt downloaded from promptUrl. Only available when status is SUCCESS.

file_uri: str | None

A file URI you can use when configuring an announcement. Only available when status is SUCCESS.

error_message: str | None

A detailed message describing why generation failed. Only present when status is FAILURE.

class wxc_sdk.telephony.text_to_speech.TtsStatusResponseStatus(*values)[source]

Bases: str, SafeEnum

An enumeration.

in_progress = 'IN_PROGRESS'
success = 'SUCCESS'
failure = 'FAILURE'
class wxc_sdk.telephony.text_to_speech.TtsVoice(*, id: str | None = None, label: str | None = None, **extra_data: Any)[source]

Bases: ApiModel

id: str | None

The voice ID used to generate the audio prompt.

label: str | None

The voice label, including the voice name and gender.

class wxc_sdk.telephony.text_to_speech.TextToSpeechApi(*, session: RestSession, base: str = None)[source]

Bases: ApiChild

generate(voice: str, text: str, language_code: str, org_id: str = None) str[source]

Generate a Text-to-Speech Prompt

Generate a text-to-speech prompt from the provided text, voice, and language.

Text-to-speech (TTS) efficiently generates prompts, greetings, and announcements by converting written text into synthesized audio using the specified voice. The generated audio functions like a recorded WAV file, eliminating the need for manual recording.

This API requires a full administrator or location administrator auth token with a scope of spark-admin:telephony_config_write.

Parameters:
  • voice (str) – The voice ID used to generate the audio prompt. Use the List Text-to-Speech Voices API to retrieve available voices.

  • text (str) – The text to convert to speech.

  • language_code (str) – The language code used to generate the audio prompt. Use the Read the List of Announcement Languages API to retrieve supported language codes.

  • org_id (str) – Generate text-to-speech for this organization.

Return type:

str

usage(org_id: str = None) TtsUsageResponse[source]

Get Text-to-Speech Usage

Retrieve text-to-speech usage information, including the number of API calls made, the maximum allowed within the time window, and the timestamp indicating when the usage will reset.

Text-to-speech (TTS) efficiently generates prompts, greetings, and announcements by converting written text into synthesized audio using the specified voice. The generated audio functions like a recorded WAV file, eliminating the need for manual recording.

This API requires a full or read-only administrator or location administrator auth token with a scope of spark-admin:telephony_config_read.

Parameters:

org_id (str) – Get text-to-speech usage for this organization.

Return type:

TtsUsageResponse

voices(org_id: str = None) list[TtsVoice][source]

List Text-to-Speech Voices

Fetch a list of available text-to-speech voices. Use the returned voice ID in the generation request.

Text-to-speech (TTS) efficiently generates prompts, greetings, and announcements by converting written text into synthesized audio using the specified voice. The generated audio functions like a recorded WAV file, eliminating the need for manual recording.

This API requires a full or read-only administrator or location administrator auth token with a scope of spark-admin:telephony_config_read.

Parameters:

org_id (str) – List text-to-speech voices supported for this organization.

Return type:

list[TtsVoice]

status(tts_id: str, org_id: str = None) TtsStatusResponse[source]

Get Text-to-Speech Generation Status

Get the status of a text-to-speech generation request by its ID. If the status is SUCCESS, the response includes promptUrl, kmsKeyUri, and fileUri to preview or use the audio prompt.

To preview the audio prompt:

  1. Download the KMS key - use the Webex Node.js SDK and provide kmsKeyUri to download the key from KMS.

2. Download the encrypted audio - The encrypted audio file content is stored in cloud and can be retrieved using promptURL.

3. Decrypt the audio content - Use the jose library to decrypt the content downloaded from promptUrl using the downloaded key.

Text-to-speech (TTS) efficiently generates prompts, greetings, and announcements by converting written text into synthesized audio using the specified voice. The generated audio functions like a recorded WAV file, eliminating the need for manual recording.

This API requires a full or read-only administrator or location administrator auth token with a scope of spark-admin:telephony_config_read.

Parameters:
  • tts_id (str) – Unique identifier of the text-to-speech generation request.

  • org_id (str) – Get text-to-speech status for this organization.

Return type:

TtsStatusResponse

base = 'telephony/config'