In social and entertainment scenarios, users often want various voice effects to improve their interactive experiences. For example, in chat rooms, a user can select a voice effect to add a virtual stereo effect to their voice.
To accomplish this, Agora RTC SDK provides preset voice effects. You can also dynamically change the users' voices, such as adjusting the pitch, setting the equalization, and reverberation modes. Try out the preset voice effects on the online Demo provided by Agora.
Agora provides an open-source sample project (VoiceEffects.java) that implements the voice beautifier and audio effects functions on GitHub. You can download it to try out this function and view the source code.
To meet the requirements for voice effects in different scenarios, Agora provides setVoiceBeautifierPreset
and setAudioEffectPreset
. You can use the following SDK preset voice effects:
Category | Scenario | |
---|---|---|
Voice beautifier setVoiceBeautifierPreset |
Chat beautifier | Audio and video scenarios focusing on a user’s speaking voice: |
Singing beautifier | Audio and video scenarios focusing on a user’s singing voice: |
|
Timbre transformation | Audio and video scenarios focusing on a user’s speaking or singing voice: |
|
Audio effect setAudioEffectPreset |
Voice changer | Audio and video scenarios focusing on a user’s speaking voice: |
Style transformation | Audio and video scenarios focusing on a user’s singing voice: |
|
Room acoustics | Audio and video scenarios focusing on a user’s speaking or singing voice: |
|
Pitch correction | Audio and video scenarios focusing on a user’s singing voice: |
|
Voice conversion setVoiceConversionPreset |
Voice conversion | Audio and video scenarios focusing on a user’s speaking or singing voice: |
Chat beautifier refers to beautifying the characteristics of male or female voices without altering the original voice beyond recognition.
You can implement the chat beautifier by the enumerations in setVoiceBeautifierPreset
as follows:
Enumeration | Description |
---|---|
CHAT_BEAUTIFIER_MAGNETIC |
(For male-sounding voice only) A more magnetic voice. Agora recommends using this enumerator to process a male-sounding voice; otherwise, you may experience vocal distortion. |
CHAT_BEAUTIFIER_FRESH |
(For female-sounding voice only) A fresher voice. Agora recommends using this enumerator to process a female-sounding voice; otherwise, you may experience vocal distortion. |
CHAT_BEAUTIFIER_VITALITY |
(For female-sounding voice only) A more vital voice. Agora recommends using this enumerator to process a female-sounding voice; otherwise, you may experience vocal distortion. |
// Beautifies the local voice by making it sound more magnetic (for male only).
mRtcEngine.setVoiceBeautifierPreset(Constants.CHAT_BEAUTIFIER_MAGNETIC);
// Disables voice effects.
mRtcEngine.setVoiceBeautifierPreset(Constants.VOICE_BEAUTIFIER_OFF);
Singing beautifier refers to beautifying male or female singing voices without greatly altering their original characteristics, as well as adding a reverberation effect.
You can implement the singing beautifier by the enumeration SINGING_BEAUTIFIER
.
setVoiceBeautifierPreset(SINGING_BEAUTIFIER)
, you can beautify a male-sounding voice and add a reverberation effect that sounds like singing in a small room. Agora recommends not using setVoiceBeautifierPreset(SINGING_BEAUTIFIER)
to process a female-sounding voice; otherwise, you may experience vocal distortion.setVoiceBeautifierParameters(SINGING_BEAUTIFIER, param1, param2)
, you can beautify a male- or female-sounding voice and add one of several reverberation effects.// Beautifies the singing voice of the local user.
mRtcEngine.setVoiceBeautifierPreset(Constants.SINGING_BEAUTIFIER);
// Beautifies a female-sounding voice and add a reverberation effect that sounds like singing in a hall.
mRtcEngine.setVoiceBeautifierParameters(Constants.SINGING_BEAUTIFIER, 2, 3);
// Disables voice effects.
mRtcEngine.setVoiceBeautifierPreset(Constants.VOICE_BEAUTIFIER_OFF);
Timbre transformation changes the timbre of a voice in a specific way. Users can choose the most appropriate effect for their voice.
You can implement the timbre transformation by the enumerations in setVoiceBeautifierPreset
as follows:
Enumeration | Description |
---|---|
TIMBRE_TRANSFORMATION_VIGOROUS |
A more vigorous voice. |
TIMBRE_TRANSFORMATION_DEEP |
A deeper voice. |
TIMBRE_TRANSFORMATION_MELLOW |
A mellower voice. |
TIMBRE_TRANSFORMATION_FALSETTO |
A falsetto voice. |
TIMBRE_TRANSFORMATION_FULL |
A fuller voice. |
TIMBRE_TRANSFORMATION_CLEAR |
A clearer voice. |
TIMBRE_TRANSFORMATION_RESOUNDING |
A more resounding voice. |
TIMBRE_TRANSFORMATION_RINGING |
A more ringing voice. |
// Beautifies the local voice by making it sound more vigorous.
mRtcEngine.setVoiceBeautifierPreset(Constants.TIMBRE_TRANSFORMATION_VIGOROUS);
// Disables voice effects.
mRtcEngine.setVoiceBeautifierPreset(Constants.VOICE_BEAUTIFIER_OFF);
Voice changer changes the original voice mainly for fun effects. This effect makes the original voice less natural, so that listeners can tell that the voice has been changed.
You can implement the voice changer effect by the enumerations in setAudioEffectPreset
as follows:
Enumeration | Description |
---|---|
VOICE_CHANGER_EFFECT_UNCLE |
The voice of an uncle. Agora recommends using this enumerator to process a male-sounding voice; otherwise, you may not hear the anticipated voice effect. |
VOICE_CHANGER_EFFECT_OLDMAN |
The voice of an old man. Agora recommends using this enumerator to process a male-sounding voice; otherwise, you may not hear the anticipated voice effect. |
VOICE_CHANGER_EFFECT_BOY |
The voice of a boy. Agora recommends using this enumerator to process a male-sounding voice; otherwise, you may not hear the anticipated voice effect. |
VOICE_CHANGER_EFFECT_SISTER |
The voice of a young woman. Agora recommends using this enumerator to process a female-sounding voice; otherwise, you may not hear the anticipated voice effect. |
VOICE_CHANGER_EFFECT_GIRL |
The voice of a girl. Agora recommends using this enumerator to process a female-sounding voice; otherwise, you may not hear the anticipated voice effect. |
VOICE_CHANGER_EFFECT_PIGKING |
The voice of Pig King, a character in Journey to the West who has a voice like a growling bear. |
VOICE_CHANGER_EFFECT_HULK |
The voice of Hulk. |
// Presets the local voice by making it sound like the Hulk.
mRtcEngine.setAudioEffectPreset(Constants.VOICE_CHANGER_EFFECT_HULK);
// Disables voice effects.
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
A style transformation makes singing more harmonious for specific styles of songs.
You can implement the style transformation by the enumerations in setAudioEffectPreset
as follows:
Enumeration | Description |
---|---|
STYLE_TRANSFORMATION_POPULAR |
An audio effect typical of popular music. |
STYLE_TRANSFORMATION_RNB |
An audio effect typical of R&B music. |
// Presets the local voice to the style of pop music.
mRtcEngine.setAudioEffectPreset(Constants.STYLE_TRANSFORMATION_POPULAR);
// Disables voice effects.
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
Room acoustics refers to the spatial dimension added to a user’s voice for making the voice seem to come from a specific type of enclosed place.
You can implement the space construction by the enumerations in setAudioEffectPreset
as follows:
Enumeration | Description |
---|---|
ROOM_ACOUSTICS_KTV |
An audio effect typical of a KTV venue. |
ROOM_ACOUSTICS_VOCAL_CONCERT |
An audio effect typical of a concert hall. |
ROOM_ACOUSTICS_STUDIO |
An audio effect typical of a recording studio. |
ROOM_ACOUSTICS_PHONOGRAPH |
An audio effect typical of a vintage phonograph. |
ROOM_ACOUSTICS_VIRTUAL_STEREO |
A virtual stereo effect that renders monophonic audio as stereo audio. Note setAudioProfile and set the profile parameter to AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5) before setting this enumerator; otherwise, the enumerator setting does not take effect.scenario parameter of setAudioProfile to AUDIO_SCENARIO_GAME_STREAMING(3) before setting this enumerator. |
ROOM_ACOUSTICS_SPACIAL |
A more spatial audio effect. |
ROOM_ACOUSTICS_ETHEREAL |
A more ethereal audio effect. |
ROOM_ACOUSTICS_3D_VOICE |
A 3D voice effect that makes the voice appear to be moving around the user. The default cycle period of the 3D voice effect is 10 seconds. To change the cycle period, call setAudioEffectParameters after this method.Note setAudioProfile and set the profile parameter to AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5) before setting this enumerator; otherwise, the enumerator setting does not take effect.scenario parameter of setAudioProfile to AUDIO_SCENARIO_GAME_STREAMING(3) before setting this enumerator. |
// Presets the local voice by making it appear to be moving around the user.
mRtcEngine.setAudioEffectPreset(Constants.ROOM_ACOUSTICS_3D_VOICE);
// Changes the cycle period to 30 seconds.
mRtcEngine.setAudioEffectParameters(Constants.ROOM_ACOUSTICS_3D_VOICE, 30, 0);
// Disables voice effects.
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
Pitch correction refers to the effect for correcting a singing voice to make it match the song based on the basic mode and the tonic pitch.
You can implement the pitch correction by the enumerations in setAudioEffectPreset
as follows:
Enumeration | Description |
---|---|
PITCH_CORRECTION |
A pitch correction effect that corrects the user's pitch based on the pitch of the natural C major scale. To change the basic mode and tonic pitch, call setAudioEffectParameters after this method. |
// Presets the local voice by making it match the song.
mRtcEngine.setAudioEffectPreset(Constants.PITCH_CORRECTION);
// Changes the basic mode to natural minor scale and the tonic pitch to D.
mRtcEngine.setAudioEffectParameters(Constants.PITCH_CORRECTION, 2, 6);
// Disables voice effects.
mRtcEngine.setAudioEffectPreset(Constants.AUDIO_EFFECT_OFF);
Voice conversion naturally changes the original voice mainly for anonymous effects. Listeners cannot tell that the voice has been changed without listening to the original voice.
You can implement the voice changer by the enumerations in setVoiceConversionPreset
as follows:
Enumeration | Description |
---|---|
VOICE_CONVERSION_OFF |
Turn off voice conversion effects and use the original voice. |
VOICE_CHANGER_NEUTRAL |
A gender-neutral voice. To avoid audio distortion, ensure that you use this enumerator to process a female-sounding voice. |
VOICE_CHANGER_SWEET |
A sweet voice. To avoid audio distortion, ensure that you use this enumerator to process a female-sounding voice. |
VOICE_CHANGER_SOLID |
A steady voice. To avoid audio distortion, ensure that you use this enumerator to process a male-sounding voice. |
VOICE_CHANGER_BASS |
A deep voice. To avoid audio distortion, ensure that you use this enumerator to process a male-sounding voice. |
// Presets the local voice by making it sound like a gender-neutral voice.
mRtcEngine.setVoiceConversionPreset(Constants.VOICE_CHANGER_NEUTRAL);
// Disables voice effects.
mRtcEngine.setVoiceConversionPreset(Constants.VOICE_CONVERSION_OFF);
If the preset effect does not meet your requirement, you can also customize the voice effects by adjusting the voice pitch, equalization, and reverberation settings through setLocalVoicePitch
, setLocalVoiceEqualization
, and setLocalVoiceReverb
.
The following sample code shows how to change the original user's voice to the Hulk's voice.
// Sets the pitch. The value ranges between 0.5 and 2.0. The lower the value, the lower the pitch. The default value is 1.0, which is the original pitch.
double pitch = 0.5;
mRtcEngine.setLocalVoicePitch(pitch);
// Sets the local voice equalization.
// The first parameter sets the band frequency. The value ranges between 0 and 9. Each value represents the center frequency of the band: 31, 62, 125, 250, 500, 1k, 2k, 4k, 8k, and 16k Hz.
// The second parameter sets the gain of each band. The value ranges between -15 and 15 dB. The default value is 0.
mRtcEngine.setLocalVoiceEqualization(0, -15);
mRtcEngine.setLocalVoiceEqualization(1, 3);
mRtcEngine.setLocalVoiceEqualization(2, -9);
mRtcEngine.setLocalVoiceEqualization(3, -8);
mRtcEngine.setLocalVoiceEqualization(4, -6);
mRtcEngine.setLocalVoiceEqualization(5, -4);
mRtcEngine.setLocalVoiceEqualization(6, -3);
mRtcEngine.setLocalVoiceEqualization(7, -2);
mRtcEngine.setLocalVoiceEqualization(8, -1);
mRtcEngine.setLocalVoiceEqualization(9, 1);
// The level of the dry signal in dB. The value ranges between -20 and 10.
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_DRY_LEVEL, 10);
// The level of the early reflection signal (wet signal) in dB. The value ranges between -20 and 10.
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_WET_LEVEL, 7);
// The room size of the reverberation. A larger room size means a stronger reverberation. The value ranges between 0 and 100.
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_ROOM_SIZE, 6);
// The length of the initial delay of the wet signal (ms). The value ranges between 0 and 200.
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_WET_DELAY, 124);
// The reverberation strength. The value ranges between 0 and 100. The higher the value, the stronger the reverberation.
mRtcEngine.setLocalVoiceReverb(Constants.AUDIO_REVERB_STRENGTH, 78);
Preset voice effects
setAudioEffectPreset
setVoiceBeautifierPreset
setAudioEffectParameters
setVoiceBeautifierParameters
setVoiceConversionPreset
Customized voice effects
profile
parameter of setAudioProfile
to AUDIO_PROFILE_SPEECH_STANDARD(1)
; otherwise, the following methods do not take effect.setAudioEffectPreset
setVoiceBeautifierPreset
setAudioEffectParameters
setVoiceBeautifierParameters
setVoiceConversionPreset
setAudioEffectPreset
setVoiceBeautifierPreset
setAudioEffectParameters
setVoiceBeautifierParameters
setVoiceConversionPreset
setLocalVoicePitch
setLocalVoiceEqualizationOfBandFrequency
setLocalVoiceReverbOfType