跳到导航

流式传输带时间信息的语音

使用所选音色将文本转换为语音,并返回 JSON 流,其中包含 base64 编码的音频字符串以及各字符的朗读时间信息。

路径参数

voice_idstring必需

要使用的音色 ID。使用 获取音色 端点列出所有可用音色。

请求头

xi-api-keystring可选

查询参数

enable_loggingboolean可选默认为 true

当 enable_logging 设为 false 时,此请求将使用零留存模式。这意味着该请求无法使用历史记录功能,包括请求拼接。零留存模式仅限企业版客户使用。

optimize_streaming_latencyinteger or null可选Deprecated

可启用延迟优化,但会牺牲部分质量。可达到的最低最终延迟因模型而异。可选值: 0 - 默认模式(不进行延迟优化) 1 - 常规延迟优化(约为选项 3 可实现延迟改善的 50%) 2 - 强延迟优化(约为选项 3 可实现延迟改善的 75%) 3 - 最大延迟优化 4 - 最大延迟优化,同时关闭文本规范化以进一步降低延迟(延迟最低,但可能会错误朗读数字、日期等)。

默认值为 None。

output_formatenum可选默认为 mp3_44100_128

生成音频的输出格式。格式为 codec_sample_rate_bitrate。因此,采样率为 22.05kHz、比特率为 32kbs 的 mp3 表示为 mp3_22050_32。使用 192kbps 比特率的 MP3 需要订阅 Creator 或更高版本。采样率为 44.1kHz 的 PCM 格式需要订阅 Pro 或更高版本。请注意,μ-law 格式(有时写作 mu-law,通常近似写作 u-law)常用于 Twilio 音频输入。

请求

This endpoint expects an object.
textstring必需

将转换为语音的文本。

model_idstring可选默认为 eleven_multilingual_v2

要使用的模型标识符,可通过 GET /v1/models 查询。模型必须支持文本转语音,可通过 can_do_text_to_speech 属性确认。

language_codestring or null可选

用于为模型和文本规范化强制指定语言的语言代码(ISO 639-1)。如果模型不支持提供的语言代码,将忽略该代码。multilingual_v2 模型不支持此参数。

voice_settingsobject or null可选

覆盖指定音色已存储设置的音色设置,仅应用于当前请求。

pronunciation_dictionary_locatorslist of objects or null可选

要应用于文本的发音词典定位符(id、version_id)列表。将按顺序应用。每次请求最多可包含 3 个定位符。

seedinteger or null可选

指定后,系统会尽力进行确定性采样,使使用相同种子和参数的重复请求返回相同结果。但不保证完全确定。必须是介于 0 和 4294967295 之间的整数。

previous_textstring or null可选

当前请求文本之前的文本。可用于提升拼接多个生成结果时的语音连贯性,或影响当前生成的语音连贯性。

next_textstring or null可选

当前请求文本之后的文本。可用于提升拼接多个生成结果时的语音连贯性,或影响当前生成的语音连贯性。

previous_request_idslist of strings or null可选

A list of request_id of the samples that were generated before this generation. Can be used to improve the speech’s continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be sent.

next_request_idslist of strings or null可选

A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech’s continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be sent.

use_pvc_as_ivcboolean or null可选

是否使用专业音色的 IVC 版本。这可能提升表现力并降低延迟。

apply_text_normalizationenum可选默认为 auto

此参数通过 3 种模式控制文本规范化:‘auto’、‘on’ 和 ‘off’。设为 ‘auto’ 时,系统会自动决定是否应用文本规范化(如将数字读出)。设为 ‘on’ 时始终应用;设为 ‘off’ 时跳过。

允许的值:
audio_effectsobject or null可选

应用于生成音频的音效。未知 ID 会返回 404,param 会指明相应字段。混响(environment_id 的 send_level 大于 0)和非零 pan 会生成立体声音频,因此 ulaw_*、alaw_* 和 pcm_* 输出格式会返回 400。音效不会改变请求费用。

apply_language_text_normalizationboolean可选默认为 falseDeprecated

此参数控制语言文本规范化,有助于部分支持语言中的文本正确发音。警告:此参数可能大幅增加请求延迟。目前仅支持日语。

响应

转录片段流

audio_base64string
Base64 encoded audio data
alignmentobject or null可选

原始文本中每个字符的时间戳信息。

normalized_alignmentobject or null可选

规范化文本中每个字符的时间戳信息。

错误

422
Unprocessable Entity Error