API reference
Streaming speech synthesis converts streaming text into binary speech data and returns the results as a real-time audio stream. This allows end users to hear the audio output almost in sync, which greatly improves the user experience by reducing waiting time. A typical scenario is sending streaming text from a large language model (LLM) directly to the streaming speech synthesis service to obtain a real-time audio stream. No processing, such as concatenation or integration, is required.
Billing and concurrency limits
Streaming speech synthesis is available only in the commercial version. This feature is not supported in the trial version. For more information, see Trial and commercial versions. To use this feature, you must subscribe to the commercial version. For more information, see Upgrade from the trial version to the commercial version.
For more information about billing methods, see Billing methods.
For more information about concurrency limits, see Concurrency and QPS limits.
Features
Supports data output in PCM, WAV, and MP3 encoding formats.
Supports streaming text. In a single session, you can send text in batches and receive the corresponding audio. The synthesized audio has low latency and can be played back in real time. The text sent in each batch does not need to be a complete word or sentence because the server-side automatically segments and reorganizes the text based on semantics.
To play the audio in real time, use an audio player that supports streaming playback. Players that support streaming playback include ffmpeg, pyaudio (Python), AudioFormat (Java), and MediaSource (JavaScript).
In a single streaming TTS session, each text batch cannot exceed 10,000 characters, and the total length of all text batches cannot exceed 200,000 characters. One Chinese character is counted as two characters. One English letter, punctuation mark, or space is counted as one character.
Supports text input in UTF-8 encoding.
Supports setting the speech rate, pitch, and volume.
Supports setting different voices.
You can configure the speech rate, pitch, volume, and voice style only before you call the startStreamInputTts function.
Supports the timestamp feature.
Supports SSML tags.
Supports LaTeX mathematical expressions.
Voice list
To experience more synthesis effects, visit the Speech Synthesis product page. This page provides samples for most voices. If a sample for a specific voice is not available on the page, you can call the API to listen to a sample.
CosyVoice-V2 voices
Name | Voice name (voice parameter value) | Type | Scenario | Supported languages | Supported sample rates | Timestamp support | SSML support |
Longcheng | longcheng_v2 | Sunny male voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longhua | longhua_v2 | Lively girl | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longshu | longshu_v2 | Male news anchor voice | News broadcasting, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Bella2.0 | loongbella_v2 | Female news anchor voice | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longwan | longwan_v2 | Mandarin female voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longxiaochun | longxiaochun_v2 | Gentle Sister | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longxiaoxia | longxiaoxia_v2 | Gentle female voice | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longhuhu | longhuhu | An innocent and carefree girl | Child's voice | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longanpei | longanpei | Young female teacher | Consumer electronics - Education and training | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longdaiyu | longdaiyu | Delicate and talented female voice | Short video dubbing | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longgaoseng | longgaoseng | Enlightened monk voice | Short video dubbing | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingmu | longyingmu | An elegant and sophisticated woman | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingxun | longyingxun | A young, inexperienced man | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingcui | longyingcui | Stern male collection agent voice | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingda | longyingda | Cheerful high-pitched female voice | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingjing | longyingjing | An unassuming and composed woman | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingyan | longyingyan | A stern and righteous woman | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingtian | longyingtian | Gentle and sweet female voice | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingbing | longyingbing | A sharp and commanding woman | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingtao | longyingtao | A woman with a gentle and calm demeanor | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyingling | longyingling | Mild and empathetic female voice | Customer service | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
YUMI | longyumi_v2 | Proper young woman | Voice assistant | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longanran | longanran | Lively and textured female voice | Livestreaming e-commerce | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longanxuan | longanxuan | Female-Hosted Live Stream | Livestreaming e-commerce | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longanchong | longanchong | Enthusiastic Salesperson | Livestreaming e-commerce | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longanping | longanping | High-pitched female livestreamer voice | Livestreaming e-commerce | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longbaizhi | longbaizhi | Wise female narrator voice | Audiobook | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longsanshu | longsanshu | Steady and textured male voice | Audiobook | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longxiu | longxiu_v2 | Erudite male storyteller voice | Audiobook | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longmiao | longmiao_v2 | Cadenced female voice | Audiobook | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyue | longyue_v2 | Warm and magnetic female voice | Audiobook | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longnan | longnan_v2 | Wise young man | Audiobook | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyuan | longyuan_v2 | Warm and healing female voice | Audiobook | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longanrou | longanrou | Gentle Best Friend | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longqiang | longqiang_v2 | Romantic and Charming Woman | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longhan | longhan_v2 | A caring and dedicated man | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longxing | longxing_v2 | Simple and friendly | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longfeifei | longfeifei_v2 | Sweet and pampered girl | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longxiaocheng | longxiaocheng_v2 | Magnetic low-pitched male voice | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longzhe | longzhe_v2 | The Endearingly Awkward Man | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longyan | longyan_v2 | Warm Spring Breeze Woman | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longtian | longtian_v2 | Magnetic-Rational Man | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longze | longze_v2 | Warm and energetic male voice | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longshao | longshao_v2 | A motivated and ambitious man | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longhao | longhao_v2 | Passionate and Melancholy Man | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longshen | kabuleshen_v2 | Talented male singer voice | Social companion | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longjielidou | longjielidou_v2 | Cheerful and Mischievous Boy | Child's voice | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longling | longling_v2 | A girl with a naive and expressionless face | Child's voice | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longke | longke_v2 | Sweet and innocent girl | Child's voice | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longxian | longxian_v2 | Bold and Cute Girl | Child's voice | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longlaotie | longlaotie_v2 | A Straight Shooter | Northeastern dialect | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longjiayi | longjiayi_v2 | Intellectual Cantonese female voice | Cantonese | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longtao | longtao_v2 | Positive Cantonese female voice | Cantonese | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longfei | longfei_v2 | Passionate and magnetic male voice | Poetry recitation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Libai | libai_v2 | Ancient Immortal Poet | Poetry recitation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longjin | longjin_v2 | Elegant and gentle male voice | Poetry recitation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longshuo | longshuo_v2 | A skilled professional | News broadcasting | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longxiaobai | longxiaobai_v2 | Steady female announcer voice | News broadcasting | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
Longjing | longjing_v2 | Typical female announcer voice | News broadcasting | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
loongstella | loongstella_v2 | An astute and capable woman | News broadcasting | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | Yes | Yes |
loongeva | loongeva_v2 | Intellectual English Woman | Overseas marketing | British English | 8 kHz/16 kHz/24 kHz | No | No |
loongbrian | loongbrian_v2 | Steady English male voice | Overseas marketing | British English | 8 kHz/16 kHz/24 kHz | No | No |
loongluna | loongluna_v2 | British English female voice | Overseas marketing | British English | 8 kHz/16 kHz/24 kHz | No | No |
loongluca | loongluca_v2 | British English male voice | Overseas marketing | British English | 8 kHz/16 kHz/24 kHz | No | No |
loongemily | loongemily_v2 | British English female voice | Overseas marketing | British English | 8 kHz/16 kHz/24 kHz | No | No |
loongeric | loongeric_v2 | British English male voice | Overseas marketing | British English | 8 kHz/16 kHz/24 kHz | No | No |
loongabby | loongabby_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongannie | loongannie_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongandy | loongandy_v2 | American English male voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongava | loongava_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongbeth | loongbeth_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongbetty | loongbetty_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongcindy | loongcindy_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongcally | loongcally_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongdavid | loongdavid_v2 | American English male voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongdonna | loongdonna_v2 | American English female voice | Overseas marketing | American English | 8 kHz/16 kHz/24 kHz | No | No |
loongkyong | loongkyong_v2 | Korean female voice | Overseas marketing | Korean | 8 kHz/16 kHz/24 kHz | No | No |
loongtomoka | loongtomoka_v2 | Japanese female voice | Overseas marketing | Japanese | 8 kHz/16 kHz/24 kHz | No | No |
loongtomoya | loongtomoya_v2 | Japanese male voice | Overseas marketing | Japanese | 8 kHz/16 kHz/24 kHz | No | No |
CosyVoice-V1 voices
Name | Voice name (voice parameter value) | Type | Scenario | Supported languages | Supported sample rates | Timestamp support | SSML support |
Longchen | longchen | Dubbed film male voice | Dubbed film | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxiong | longxiong | Dubbed film male voice | Dubbed film | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longyu | longyu | Mature older sister voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longjiao | longjiao | Mature older sister voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longmei | longmei | Gentle female voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longgui | longgui | Gentle female voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longping | longping | Male sports commentator voice | Sports commentary | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longpang | longpang | Male sports commentator voice | Sports commentary | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longwu | longwu | Nonsensical male voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longqi | longqi | Lively child's voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxian | longxian_normal | Sunny female voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longfei | longfeifei | Mature female voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxiu | longxiu | Young male voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longdachui | longdachui | Humorous male voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longjiajia | longjiajia | Approachable female voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longjiayi | longjiayi | Cantonese female voice | Chat, news broadcasting, audiobooks, in-car navigation | Cantonese and Cantonese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longtao | longtao | Cantonese female voice | Chat, news broadcasting, audiobooks, in-car navigation | Cantonese and Cantonese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longjiaxin | longjiaxin | Cantonese female voice | Chat, news broadcasting, audiobooks, in-car navigation | Cantonese and Cantonese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longcheng | longcheng | Sunny male voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longzhe | longzhe | Mature male voice | Chat, news broadcasting, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longnan | longnan | Young male voice | News broadcasting, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longyan | longyan | Friendly female voice | Intelligent customer service, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longqiang | longqiang | Languid female voice | Chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longhua | longhua | Lively girl | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxing | longxing | Heartwarming female voice | Intelligent customer service, chat | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longjin | longjin | Young male voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longhan | longhan | Young male voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longtian | longtian | Overbearing CEO male voice | Chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longshuo | longshuo | Steady male voice | Intelligent customer service, news broadcasting, audiobooks, | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Stella2.0 | loongstella | Brisk female voice | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxiaocheng | longxiaocheng | Dapper gentleman | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxiaoxia | longxiaoxia | Gentle female voice | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxiaochun | longxiaochun | Gentle Sister | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longxiaobai | longxiaobai | Female chat voice | News broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longlaotie | longlaotie | Northeastern male voice | Chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longyue | longyue | Female storyteller voice | Intelligent customer service, news broadcasting, audiobooks, | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Bella2.0 | loongbella | Female news anchor voice | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longshu | longshu | Male news anchor voice | News broadcasting, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longjing | longjing | Serious female voice | News broadcasting, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longmiao | longmiao | Classy female voice | Intelligent customer service, news broadcasting, chat, audiobooks, in-car navigation | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longlaoli | libai | Mandarin male voice | Poetry recitation, prose, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longwan | longwan | Mandarin female voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longke | longke | Lively girl | Intelligent customer service, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longling | longling | Lively girl | Intelligent customer service, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longshao | longshao | Energetic male voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longze | longze | Sunny male voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Longhao | longhao | Warm male voice | Intelligent customer service, news broadcasting, chat, audiobooks | Chinese and Chinese-English mixed | 8 kHz/16 kHz/24 kHz | No | No |
Endpoints
Access type | Description | URL |
Public network access | All servers can use the public network access URL. The public network access URL is configured by default in the software development kit (SDK). | Beijing: |
ECS internal network access | If you use an Alibaba Cloud ECS instance in the China (Beijing) region, you can use the internal network access URL. ECS instances in a classic network cannot access AnyTunnel. This means they cannot access Voice Service over the internal network. To use AnyTunnel, create a VPC and access the service from within the VPC. Note If you use internal network access, no data transfer cost is incurred for the ECS instance. For more information about ECS network types, see Network types. | Beijing: |
Interaction flow
Authentication
The client uses a token for authentication when establishing a WebSocket connection with the server-side. For more information about how to obtain a token, see Overview of obtaining a token.
Start synthesis
The client initiates a speech synthesis request and configures the required parameters in the request message. You can set each parameter using the set method of the StreamInputTts object in the SDK. The following table describes the parameters.
Parameter
Type
Required
Description
appkey
String
Yes
The Appkey of the project that you created in the console. To obtain an Appkey, go to the console.
voice
String
Yes
The voice of the speaker.
format
Enumeration/String
No
The audio coding format. It is an enumeration type in OutputFormatEnum. Valid values:
.opus,.pcm,.wav, and.mp3. Default value:.pcm.sample_rate
Enumeration/Integer
No
The audio sampling rate. Default value: 16000 Hz. It is an enumeration type in SampleRateEnum. Valid values: SAMPLE_RATE_8K, SAMPLE_RATE_16K, SAMPLE_RATE_24K, and SAMPLE_RATE_48K.
volume
Integer
No
The reading volume. Valid values: 0 to 100. Default value: 50.
speech_rate
Integer
No
The reading speech rate. Valid values: -500 to 500. Default value: 0.
pitch_rate
Integer
No
The reading pitch. Valid values: -500 to 500. Default value: 0.
bit_rate
Integer
No
The bitrate of the audio. This parameter is valid only for OPUS encoding. Valid values: 6 to 510 kbps. Default value: 32.
usage
object
No
The billing information, which indicates the number of characters consumed by the request.
(One Chinese character counts as two characters. One English letter, one punctuation mark, or one space between words counts as one character.)
enable_aigc_tag
boolean
No
Specifies whether to add an invisible AIGC identifier to the generated audio. If you set this to true, the invisible identifier is embedded into the audio in a supported format (WAV, MP3, or Opus).
Default value: false.
aigc_propagator
String
No
Sets the
ContentPropagatorfield in the invisible AIGC identifier to identify the content propagator. This parameter is valid only whenenable_aigc_tagistrue.Default value: Your Alibaba Cloud UID.
aigc_propagate_id
String
No
Sets the
PropagateIDfield in the invisible AIGC identifier to uniquely identify a specific propagation behavior. This parameter is valid only whenenable_aigc_tagistrue.Default value: The Task ID of the current speech synthesis request.
Receive synthesized data
The server-side returns the synthesized binary speech data. The SDK then receives and processes this binary data.
End synthesis
When the speech synthesis is complete, the server-side sends a notification event. The following code shows an example of the notification event.
{ "header": { "message_id": "05450bf69c53413f8d88aed1ee60****", "task_id": "640bc797bb684bd6960185651307****", "namespace": "FlowingSpeechSynthesizer", "name": "SynthesisCompleted", "status": 20000000, "status_message": "GATEWAY|SUCCESS|Success." } }