Integrate the basic voice cloning web SDK
Integrate the voice cloning service into your front-end web pages by using the basic web SDK provided by Intelligent Production.
Usage
The following procedure applies to version 0.0.2 of the basic voice cloning web SDK.
The voice cloning process consists of four steps: 1) Environment check: Grant microphone access and ensure a quiet environment. 2) Record 20 high-quality audio clips: Use your phone's built-in microphone, keeping it about 10 cm away, and speaking clearly and expressively. 3) Wait for voice training: The cloning process takes about 30 minutes to complete. 4) Audition and use: Review the results on the Customized Voice page in the Alibaba Cloud console. After agreeing to the Customized Voice Service Agreement, click Start cloning.
Procedure
-
Import the voice cloning web SDK in the
<head>tag of your front-end page.<head> <script src="https://g.alicdn.com/video-cloud-fe/tts-factory/0.0.2/index.js"></script> </head>Add a
<div>node in the<body>tag to serve as the component's mount point.<body> <div id="app" ></div> // You can change the height of the container as needed. </body> -
Initialize the web SDK.
-
API definition:
-
InitConfig
interface InitConfig { container: HTMLElement; api: { // Create a voiceId. createVoiceId: (params: { voiceId?: string, voiceName: string, gender: string, scenario: string }) => Promise<Result<{ voiceId: string }>>; // Get the list of recording prompts. getRecorderList: (params: { sex: string, scenario: string }) => Promise<Result>; // Upload a recorded audio clip. uploadRecord: (params: any) => Promise<Result<{fileUrl: string}>>; // Validate a recorded audio clip. validRecord: (params: any) => Promise<Result<{ reason: string; pass: boolean }>>; // Submit the recorded audio clips. submitRecord: (params: any) => Promise<Result>; // Customize UI text. getCopywriting?:(config: any)=>T; } } -
AliyunTTSFactory class
class AliyunTTSFactory { destroy(): void }
-
-
Sample code
-
-
Call the
destroy()method to release the instance. After the instance is destroyed, the container becomes an empty element.ttsFactory.destroy();
Sample code
References
To learn more about voice cloning, see Voice cloning.