Voice effects
Voice SDK makes it simple for you to publish audio captured through the microphone to subscribers in a channel. In some cases, users want to modify the captured audio to add voice effects, or change the voice quality before the audio is published. Voice SDK provides several options that enable you to apply voice effects. This page shows you how to implement these features in your channel.
Understand the tech
Voice effects are gaining popularity in social interaction and entertainment scenarios. To help you quickly integrate voice effects into your project, Voice SDK provides pre-configured effects. Choose from the following effects:
-
Voice beautifiers
- Voice beautifier for Chat: Beautify the voice in chat scenarios according to the characteristics of male and female voices without changing the original voice recognition.
- Singing beautifier: Beautify the singing voice according to male and female voice characteristics while retaining the original character of the singing voice.
- Timbre shift: Fine-tune the timbre of a vocal in a specific direction.
-
Sound effects
- Style sound effects: For songs of a specific style, make the singing and accompaniment more compatible.
- Spatial shaping: Create a spatial atmosphere through spatial reverberation effects. Make the vocals seem to come from a specific source.
- Electronic sound effects: Adjust the pitch of the vocals to perfectly match the key and pitch of the accompaniment for an electronic sound effect.
-
Voice changer
- Basic voice changing: Make the voice more neutral, sweet, or stable while retain a certain degree of voice recognition.
- Advanced voice changing: Dramatically change the human voice to realize voices of uncle, girl, Hulk, etc.
-
Custom audio effects If the preset effects don't meet your needs, manually adjust the voice pitch, equalization, and reverberation to achieve a customized effect.
Try the Online Demo to experience different voice effects.
Prerequisites
Before proceeding with the code examples on this page, make sure you have completed the SDK quickstart guide.
Implement voice effects
This section shows how to use different sound beautifiers to enhance your audio experience.
Use the following methods to set the desired vocal effects:
- Call the
setVoiceBeautifierPreset
method to apply effects such as chatting bel canto, singing bel canto, and timbre change. - Utilize the
setAudioEffectPreset
method to configure sound effects, genre sound effects, space shaping, and other effects. - Apply the
setVoiceConversionPreset
method to entirely transform the original voice. If the preset effects don't meet your requirements, customize vocal effects using methods such assetLocalVoicePitch
,setLocalVoiceEqualization
, andsetLocalVoiceReverb
.
Choose the one that best fits your requirements. To implement various voice effects in your project, take the following steps:
Set audio scenario and audio profile
For optimal audio quality, take the following steps:
-
Call setAudioScenario to set the audio scenario to high-quality
AUDIO_SCENARIO_GAME_STREAMING
. -
Call setAudioProfile to set the audio encoding properties to high-quality encoding:
- For mono transmission, set the profile to
AUDIO_PROFILE_MUSIC_HIGH_QUALITY
. - For stereo transmission, set the profile to
AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO
- For mono transmission, set the profile to
Voice beautifiers
Call setVoiceBeautifierPreset
to set music style, space shaping, electronic music, and other effects.
-
Chat voice beautifier
-
Singing voice beautifier
-
Tone change
Sound effects
Call setAudioEffectPreset
to set music style, space shaping, electronic music and other effects.
-
Music Style
-
Space shaping
-
Electronic sound effects
Voice change effects
To implement basic voice-changing effects, call the setAudioEffectPreset
method. For advanced voice-changing effects, use the setVoiceConversionPreset
method.
-
Basic voice changer
-
Advanced voice changer
Custom audio effects
Call setLocalVoicePitch
, setLocalVoiceEqualization
, and setLocalVoiceReverb
to fine-tune vocal output parameters, including pitch, equalization, and reverberation effects. The following example shows you how to transform a human voice into the voice of the Hulk by manually setting parameter values:
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
Development considerations
-
Only one vocal effect can be set at a time. If multiple effects are set, the last one overwrites the previous one.
-
The enumerations in
setVoiceBeautifierPreset
,setAudioEffectPreset
,setVoiceConversionPreset
, and other preset methods are optimized for different genders and should be used appropriately. Using these presets on vocals of the opposite gender may cause distortion. For more details, see API reference.
Sample project
Agora provides an open source Voice effects project on GitHub for your reference. Download or view the source code for a more detailed example.
API reference
Audio scenario and audio profile
Preset voice effects
- setVoiceBeautifierPreset
- setAudioEffectPreset
- setVoiceConversionPreset
- setAudioEffectParameters
- setVoiceBeautifierParameters