Huawei audio editing service changes voice in real time, uncle voice and monster voice at will

Time:2022-5-16

Voice change is a function often used by users in live broadcast and chat applications. For example, many anchors choose to use sound transformers to drive the atmosphere of the live broadcast room; When chatting with friends, choose to become Lori tone to make the chat more interesting. HMS core audio editing service provides sound change capability to help developers build sound change function in applications. Users can change the sound through the preset sound changing style to improve the audio playability and effectively protect users’ privacy, so that you can change as you want.

At present, HMS core audio editing service can provide 7 sound changing effects, including uncle, Lori, boy, girl, monster, cartoon and robot. Unlimited languages, real-time processing, simple and convenient application in audio and video communication or mutual entertainment live broadcast scenes, providing real-time sound changing effects for the anchor, making the live broadcast sound more pleasant and interesting.

Sound changing effect

Now let’s practice how to access Huawei audio editing service to achieve sound change effect.

1. Development preparation

For detailed preparation steps, please refer to the official website of Huawei developer Alliance:https://developer.huawei.com/consumer/cn/doc/development/Media-Guides/config-agc-0000001154009063?ha_source=hms1

2 Edit engineering integration

2.1 setting the authentication information of the application

Developers need to use APIs_ Key or access token to set application authentication information.

Set the access token through setaccesstoken method and initialize the setting when the application starts

HAEApplication.getInstance().setAccessToken("your access token");

Set API through setapikey method_ Key, which can be initialized and set once when the application starts, without multiple settings.

HAEApplication.getInstance().setApiKey("your ApiKey");

2.2 document interface

Call the file interface to realize specific functions. Necessary conditions: create a file interface callback.

private ChangeSoundCallback callBack = new ChangeSoundCallback() {
    @Override
    public void onSuccess(String outAudioPath) {
        //Successful processing
    }
    @Override
    public void onProgress(int progress) {
        //Progress callback processing
    }
    @Override
    public void onFail(int errorCode) {
        //Processing failed
    }
    @Override
    public void onCancel() {
        //Cancel processing
    }
};

2.3 realize sound change function

Call the applyaudiofile interface to change the sound.

//Sound change
HAEChangeVoiceFile haeChangeVoiceFile = new HAEChangeVoiceFile();
ChangeVoiceOption changeVoiceOption = new ChangeVoiceOption();
changeVoiceOption.setSpeakerSex(ChangeVoiceOption.SpeakerSex.MALE);
changeVoiceOption.setVoiceType(ChangeVoiceOption.VoiceType.CUTE);
haeChangeVoiceFile.changeVoiceOption(changeVoiceOption);
//Call interface
haeChangeVoiceFile.applyAudioFile(inAudioPath, outAudioDir, outAudioName, callBack);
//Cancel voice change task
haeChangeVoiceFile.cancel();

In addition to voice change, Huawei audio editing service also provides developers with one-stop audio editing services, covering dozens of professional capabilities required for audio / music processing. Developers only need to obtain strong audio processing capabilities through simple integration, which can greatly help customers improve the processing efficiency of audio / music.

Learn more > >

visitOfficial website of Huawei developer Alliance
obtainDevelopment guidance document
Huawei mobile service open source warehouse address:GitHubGitee

Follow us and learn the latest technical information of HMS core at the first time~