Skip to content
How to Add Voice Changing Feature in Your Android Application with Agora and Voicemod featured

Extensions Marketplace: How to Add Voice Changing Feature in Your Android Application with Agora and Voicemod

By Author: Rishav Naskar In Developer

When I say video chat app, you may think I mean another generic application like Zoom or Google Meet. But you can make the app more than that by adding unique features, such as AR face filters.

Back in September of this year, Agora announced Extensions Marketplace at the RTE2021 conference. Extensions Marketplace is a revolutionary solution to add many unique, superpower features to an app without the hurdles and negotiation with various vendors and research into compatibility. It makes adding fun features very easy and straightforward.

Today, let me walk you through the process of implementing a voice-changing feature in an Android application so that your users can change voices and tunes during video call sessions.

We will use the Agora Android SDK and Voicemod from Extensions Marketplace. Let’s get started!

How to Add Voice Changing Feature in Your Android Application with Agora and Voicemod 1
Super excited!

Introduction

In this article, we have covered everything necessary to set up a simple 1–1 video calling android app with voice changing feature using Agora Android Video Call SDK and Voicemod extension.

Topics covered:

  • Prerequisites needed to set up the project
  • How to set up a basic video calling app using Agora Android SDK
  • How to activate the Voicemod extension from the Agora console
  • How to link the extension in our local project
  • Necessary code modifications needed to use the extension and stopping the extension
  • How to run the app, plus other resources for reference

Prerequisites

Project Setup

We need to first set up a basic video-calling app using the Agora Android UI Kit. Follow the steps below to set up your project.

  1. Initialize your Android project
  2. Download this GitHub repository (ngsdk-update branch)
  3. Import the “agorauikit_android” folder as a module into your project from the downloaded Android UI Kit project
  4. Add the following permissions in your AndroidManifest.xml
Permissions to be added in the AndroidManifest.xml file

5. Add the following code in your project-level build.gradle

Project Level build.gradle

Getting Started

Activate the Voicemod Extension

To activate an extension:

  1. Log in to Agora Console.
  2. In the left navigation panel, click Extensions Marketplace, then click the extension you want to activate.
    You are now on the extension detail page.
  3. Select a pricing plan and click the Activate button.
  4. If you have created an Agora project, the Projects section appears and lists all of your projects.
  5. If you do not have any Agora project, create a new project on the Project Management page. Once the project is created, it appears in the Projects section.
  6. Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
How to Add Voice Changing Feature in Your Android Application with Agora and Voicemod 4

Get APIKey and APISecret

The apiKey and apiSecret are credentials used by extension vendors for authentication purposes. They prove that you are authorized to use the extension.

To get your apiKey and apiSecret, find the project you are using under Projects on the extension detail page, then click the View button in the Secret column.

Download the extension and Agora SDK

To download the extension, click this link. This will be an Android Archive (.aar) file. We will talk about adding this file to our project in the next section.

Great going so far! We are halfway done. Now we will begin with Using the extension we just activated.

How to Add Voice Changing Feature in Your Android Application with Agora and Voicemod 2
Success!

Using the Extension

  • Place the downloaded Android Archive (.aar) file in two places, first in /app/libs and secondly in /agorauikit_android/libs.
  • Add the following code to your build.gradle at app/build.gradle and at /agorauikit_android/build.gradle.kts.
App Level build.gradle

Setting up the video call

Add the following code to initialize the Agora Android UI Kit and get started.

  • Create a new Java/Kotlin file and name it ConnectionData. Add the following code in that file.
File containing sensitive data
  • To initialise the Agora Android UI Kit, create an AgoraVideoViewer instance in app/src/main/java/com.example<projectname>/MainActivity or the activity used for the video call
Initializing the Android UI Kit in CallActivity
  • Check if permissions have been given. If not, request permissions and join the desired channel.
Checking and Requesting for permissions

Enable and use the extension

Enabling the extension is super easy, thanks to the Agora Android SDK. All we need to do is the following:

  • Add the extension to the RtcEngineConfig. The add extension function has the extension name as a parameter. This is a very crucial step because it will help us use the extension later in our project.

Add the following code in /agorauikit_android/src/main/java/io/agora/agorauikit_android/AgoraVideoViewer.kt in the initAgoraEngine() function.

Adding the extension in the Android UI Kit

Initialize the Voicemod extension

Now that we have added the extension to our engine, the next step is to initialize the extension. The following steps must be followed:

  • The setExtensionProperty of the RTCEngine class takes the extension’s vendor name, the extension’s Audio Filter name, the key “vcmd_user_data”, and our userData.
  • userData consists simply of the APIKey and the APISecret obtained from the Agora Console when you enabled the extension there. If you haven’t stored them, you can go to the console and obtain them again.
  • Strictly follow the format of the userData string shown below to avoid errors:
  • All required names of the extension can be easily called using the ExtensionManager class, without having to write them ourselves.

Add the following code for initVoiceMod() function.

Initializing Voicemod Extension

Run the Voicemod session

Now that we have successfully added and initialized our extension, it’s time for giving it a go!

  • There is a list of supported voices. We can choose any one of these.
  • We again use the setExtensionProperty of the RTCEngine class, but this time for the key “vcmd_voice”. We need to pass the following strings to the function: The extension’s vendor r name, the Audio Filter name, the key “vcmd_voice”, and the name of one of the supported voices as a String. Remember that the voices are predefined and that only these voices are currently supported.
  • We should always wrap the code around with a try-catch block to avoid app crashes and easier debugging/logging:

Add the following code for runVoiceMod() function.

Running Voicemod Extension

And we have successfully ran the Voicemod extension! Congratulations!!

How to Add Voice Changing Feature in Your Android Application with Agora and Voicemod 3
Kudos on making it this far

Stop the Voicemod session

Now that we have successfully ran the Voicemod Extension, we should also remember to stop the extension. The rest of the code is same as that of disposing a Agora Android Video call SDK.

While this is not required to run the extension, it’s extremely important to add the following code to prevent app crashes and memory leaks.

  • We use enableExtension function of the RTCEngine class. Simply pass the Extension’s vendor name, Extension’s Audio Filter name and pass false as the third parameter.
Stopping the Voicemod Extension

Test the extension

To test whether the extension works properly, follow these steps:

  1. Connect the Android device to the computer.
  2. Click Run app on your Android Studio. A moment later you will see the project installed on your device.
  3. When the app launches, start speaking and you will notice the change in your voice once you start speaking.

Conclusion

Congratulations! You now have your video calling application with a cool voice changing effect and perfect understanding of the Agora Android SDK and Voicemod extension.

You can get the complete code for this application here.

Also, you may refer to this repository for a better understanding.

And take a look at the complete documentation for the Voicemod discussed above here.

Other Resources

For more information about Agora applications, take a look at the Agora Video Call Quickstart Guide and Agora API Reference.

I also invite you to join the Agora Developer Slack community.


Want to build Real-Time Engagement apps?

Get started with 10,000 free minutes today!

If you have questions, please call us at 408-879-5885. We’d be happy to help you add voice or video chat, streaming and messaging into your apps.