The AI voice changer changes a user's voice as needed while retaining the original speed, emotion, and pitch, guaranteeing user experience with its ultra-low latency in real-time communication scenarios, such as social media voice chat, live streaming, and in-game voice chat.
Original sound | After AI voice change | After AI voice change | |
---|---|---|---|
Young men |
|||
Adult male 1 |
|||
Original voice | After AI voice change | |
---|---|---|
Adult male 1 |
||
Adult male 2 |
||
Adult female 1 |
||
Adult female 2 |
This feature is applicable to the following real-time scenarios.
Before you implement the AI voice changer feature, ensure that the following conditions are met:
Below are steps for configuring the AI voice changer.
Ensure that you have contacted ZEGO technical support to build a package for the AI voice changer and granted permission for this feature.
Initialize the ZEGO Express SDK and log in to a room. For more information, see 3.1 Create a ZegoExpressEngine instance and 3.2 Log in to a room in the "Implementation steps" section of the "Implement a basic video call" topic in the "Video Call" documentation.
To create an AI voice changer instance, call the createAIVoiceChanger operation.
You can create only one instance at a time. If you create a second instance before calling the destroyAIVoiceChanger operation to destroy the existing one, null
will be returned.
// Create an AI voice changer instance.
aiVoiceChanger = ZegoExpressEngine.getEngine().createAIVoiceChanger();
To set event callbacks for the AI voice changer, call the ZegoAIVoiceChanger.setEventHandler operation.
// Set event callbacks for the AI voice changer.
aiVoiceChanger.setEventHandler(new IZegoAIVoiceChangerEventHandler() {
@Override
public void onInit(ZegoAIVoiceChanger aiVoiceChanger, int errorCode) {
super.onInit(aiVoiceChanger, errorCode);
}
@Override
public void onUpdate(ZegoAIVoiceChanger aiVoiceChanger, int errorCode) {
super.onUpdate(aiVoiceChanger, errorCode);
}
@Override
public void onGetSpeakerList(ZegoAIVoiceChanger aiVoiceChanger, int errorCode, ArrayList<ZegoAIVoiceChangerSpeakerInfo> speakerList) {
super.onGetSpeakerList(aiVoiceChanger, errorCode, speakerList);
}
});
To initialize the AI voice changer instance, call the ZegoAIVoiceChanger.initEngine operation.
The ZegoAIVoiceChanger.initEngine operation must be called before you call the startPublishingStream operation.
// Initialize the AI voice changer instance.
aiVoiceChanger.initEngine();
To update the AI voice changer instance, call the ZegoAIVoiceChanger.update operation. The first update will take a long time due to the large size of the instance file.
// Update the AI voice changer instance.
aiVoiceChanger.update();
To obtain the list of available timbres, call the ZegoAIVoiceChanger.getSpeakerList operation.
The list will be returned in the IZegoAIVoiceChangerEventHandler.onGetSpeakerList callback.
// Obtain the list of available timbres.
aiVoiceChanger.getSpeakerList();
Call the ZegoAIVoiceChanger.setSpeaker operation to specify a timbre from the list obtained in 5. Obtain the list of timbres.
If the timbre ID is set to 0
, the original voice is used.
// Specify a timbre.
int speakerID = 0; // The timbre ID.
aiVoiceChanger.setSpeaker(speakerID);
Call the destroyAIVoiceChanger operation to destroy the AI voice changer instance and release resources, such as the microphone.
// Destroy the AI voice changer instance.
ZegoExpressEngine.getEngine().destroyAIVoiceChanger(aiVoiceChanger);
What should I do if the following error occurs when building the .apk package?
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
The error is due to the missing kotlin-stdlib
dependency. You can add it to the build.gradle
file and build the .apk
package again.
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.30'
}