targetModel using the original audio for improved cloning results.Scenarios
- Companion scenarios: Provide personalized companionship by cloning family members' voices. You can use it for smart assistants, in-car navigation, and home entertainment. For example, you can read picture books to family members, control home appliances, or provide educational guidance.
- Education scenarios: Clone teachers' voices to enhance teacher-student interaction. Enrich teaching videos and courseware. This creates a more engaging and vivid learning experience.
- Audio and video industry: Clone streamers' voices for post-production re-recording and dubbing. This improves audio and video production efficiency.
- Intelligent customer service: Clone account managers' voices to provide voice services. This includes customer callbacks and marketing calls, which enhances service personalization and human interaction.
Benefits
- Low audio sample requirements: You can clone voices with only 10 to 20 seconds of recording. This significantly reduces recording costs and improves efficiency.
- High fidelity: Using Alibaba Speech Lab's self-developed CosyVoice generative neural network Large Language Model (LLM) algorithm, combined with cutting-edge zero-shot learning technology, it accurately restores real human voices in terms of intonation, rhythm, and emotional expression, making them difficult to distinguish from real recordings.
- Instant synthesis: It restores real voice timbre in seconds, providing an efficient, real-time voice cloning service.
Supported Models
The voice cloning service supports cosyvoice-v1 and cosyvoice-v2 models.
Notes
Note the following when using the CosyVoice Voice Cloning service:
-
Audio file format requirements:
- Number of sound channels: Mono or Stereo
- Sample rate: Greater than or equal to 16,000 Hz
- Format: WAV (16bit), MP3, M4A
- File size: Up to 10 MB
- Audio duration: 10 to 20 seconds. Do not exceed 60 seconds. Maintain continuity when reading. Include at least one continuous speech segment longer than 5 seconds.
- Voice cloning quantity limit: Each Alibaba Cloud account can clone a maximum of 1,000 voices. If your needs exceed this limit, contact our pre-sales team in advance or join the developer group. Voices that remain unused for over 1 year will be taken offline.
- Copyright and legality: You are responsible for the ownership and legal rights to use the provided voice. Read the Terms of Service.
- Using cloned voices: Voices (VoiceName) generated using the voice cloning service are used in the same way as official default voices, such as longxiaoxia, provided in the Java SDK.
- Service invocation method: The voice cloning service currently supports API invocation only.
Billing
The Voice Cloning service is provided free of charge, but charges apply when you use the cloned voice for speech synthesis. For billing details, see CosyVoice Speech Synthesis.
Prerequisites
- You have activated the service and obtained an API key. We recommend that you configure your API key as an environment variable (being phased out and integrated into the Configure API Key procedure) to reduce the risk of API key leakage.
- Install the latest version of the SDK.
- An audio URL accessible over the public network is available. We recommend uploading the audio to OSS.
API Details
When using different APIs, ensure that you use the same account for all operations.
Create Voice
- Python
- Java
- RESTful
create_voice method of the VoiceEnrollmentService class. Import the VoiceEnrollmentService class as follows: from dashscope.audio.tts_v2 import VoiceEnrollmentService.The create_voice method returns a voice ID. You can use this ID for CosyVoice speech synthesis as a voice.Query all voices
- Python
- Java
- RESTful
list_voices method of the VoiceEnrollmentService class to query all voices. Import the VoiceEnrollmentService class as follows: from dashscope.audio.tts_v2 import VoiceEnrollmentService.There are two timbre states:- UNDEPLOYED: cannot be invoked
- Callable
Parameter | Type | Description |
|---|---|---|
voice_id | string | The voice ID. You can use this ID for CosyVoice speech synthesis. |
gmt_create | string | The time when the voice was created. |
gmt_modified | string | The time when the voice was last modified. |
status | string | The status.
|
Query a specific voice
- Python
- Java
- RESTful
query_voices method of the VoiceEnrollmentService class to query a specific voice. Import the VoiceEnrollmentService class as follows: from dashscope.audio.tts_v2 import VoiceEnrollmentService.Parameter | Type | Description |
|---|---|---|
resource_link | string | The URL of the audio file for cloning. |
target_model | string | The model used for voice cloning. |
gmt_create | string | The time when the voice was created. |
gmt_modified | string | The time when the voice was last modified. |
status | string | The status.
|
Update voice
- Python
- Java
- RESTful
update_voice method of the VoiceEnrollmentService class. Import the VoiceEnrollmentService class as follows: from dashscope.audio.tts_v2 import VoiceEnrollmentService.Delete a voice
- Python
- Java
- RESTful
delete_voice method of the VoiceEnrollmentService class. The VoiceEnrollmentService class is imported as follows: from dashscope.audio.tts_v2 import VoiceEnrollmentService.Use a cloned voice for speech synthesis
This document describes the voice management API. You can use it to create, query, update, and delete voices. To use a cloned voice for speech synthesis, follow these steps. Make sure to use the same account for both voice cloning and speech synthesis:
- Obtain the voice ID Call the Create Voice or Query Voice List API to obtain the voice ID.
-
Call the CosyVoice speech synthesis API
Select the API documentation for your programming language. Pass the voice ID that you obtained in Step 1 as the
voiceparameter to the synthesis API:- Java: Java SDK
- Python: Python SDK
- Other programming languages (such as Go, C#, PHP, and Node.js): WebSocket API
- The concurrent call limit for the
VoiceEnrollmentServiceAPI is 10 RPS. - The concurrent call limit for speech synthesis with a cloned voice is 3 RPS, which is the same as for standard CosyVoice voices.
Error codes
If an error occurs during a call in the Python SDK, the system throws a VoiceEnrollmentException. This exception includes a status code, an error code, and an error message.
NoApiKeyException or a InputRequiredException.
The following table lists the error codes for Voice Clone.
HTTP return code | Error code | Error message (The specific message may vary by scenario.) | Description |
|---|---|---|---|
415 | BadRequest.UnsupportedFileFormat | File format unsupported. | The file format is not supported. |
416 | BadRequest.ResourceNotExist | The required resource does not exist. | The resource does not exist for an update, query, or delete API call. |
430 | Audio.DecoderError | Failed to decode the audio file. | Failed to decode the audio file. |
430 | Audio.FileSizeExceed | File too large | The file size exceeds the limit. The voice clone file must be smaller than 10 MB. |
430 | Audio.AudioRateError | File sample rate unsupported | The file sample rate is not supported. The sample rate must be 16 kHz or higher. |
430 | Audio.AudioSilentError | Silent file unsupported | The file contains only silence, or the non-silent part is too short. Voice cloning requires more than 10 seconds of valid audio. |
500 | InternalError | Audio preprocess server error | The audio file is invalid. For example, the audio has issues, such as noise or fluctuating volume. |