Set the Voice Effect
Introduction
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.
Sample project
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.
Use preset voice effects
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
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. |
Singing beautifier
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
.
- If you call
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 usingsetVoiceBeautifierPreset(SINGING_BEAUTIFIER)
to process a female-sounding voice; otherwise, you may experience vocal distortion. - If you call
setVoiceBeautifierParameters(SINGING_BEAUTIFIER, param1, param2)
, you can beautify a male- or female-sounding voice and add one of several reverberation effects.
Timbre transformation
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. |
Voice changer
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. |
Style transformation
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. |
profile
parameter to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4)
or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5)
before setting this enumerator; otherwise, the enumerator setting does not take effect.setAudioProfile
to AUDIO_SCENARIO_GAME_STREAMING(3)
before setting this enumerator.Room acoustics
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. |
Pitch correction
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. |
Voice conversion
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. |
Customize voice effects
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.
API reference
Preset voice effects
setAudioEffectPreset
setVoiceBeautifierPreset
setAudioEffectParameters
setVoiceBeautifierParameters
setVoiceConversionPreset
Customized voice effects
Considerations
- Do not set the
profile
parameter ofsetAudioProfile
toAUDIO_PROFILE_SPEECH_STANDARD(1)
; otherwise, the following methods do not take effect. setAudioEffectPreset
setVoiceBeautifierPreset
setAudioEffectParameters
setVoiceBeautifierParameters
setVoiceConversionPreset
- All methods mentioned in this article work best with the human voice. Agora does not recommend using them for audio containing both music and voice.
- Agora recommends not calling the following methods together, because the method called subsequently overrides whichever one is called before it:
setAudioEffectPreset
setVoiceBeautifierPreset
setAudioEffectParameters
setVoiceBeautifierParameters
setVoiceConversionPreset
setLocalVoicePitch
setLocalVoiceEqualizationOfBandFrequency
setLocalVoiceReverbOfType