当前位置:网站首页>Gospel of audio and video developers, rapid integration of AI dubbing capability
Gospel of audio and video developers, rapid integration of AI dubbing capability
2022-06-12 18:05:00 【Hmscore technical team】
The creator of audio and video content has great influence on the editing application AI The demand for dubbing is increasing day by day . It has many advantages , It can not only solve the cost of employing human dubbing, but also the creator's own accent 、 Language and other restrictions , It can also greatly improve production efficiency . such as , The playing time of short video is as short as tens of seconds , Long vlog Types of videos are 4-5 minute , Use AI The dubbing function can realize multiple editing needs in a short time .
HMS Core Audio editing service (Audio Editor Kit) Provide AI Dubbing service , Help developers easily build speech synthesis functions in applications , One key output text can convert voice . It supports cute children's voice , Kind female voice , Sunshine male voice , English male voice 、 Female voice and other styles and timbres , You can also customize the timbre you want . The tone is natural and smooth , Emotional , Meet the needs of audio reading 、 Audio content production 、 Clips and other popular scenes concerned by developers .
Developing actual combat
1. The development of preparation
For detailed preparation steps, please refer to the official website of Huawei developer alliance :
2. Edit project integration
2.1 Set the authentication information of the application
Developers need to go through api_key perhaps Access Token To set the application authentication information .
- ( recommend ) adopt setAccessToken Method setting Access Token, Initialize settings when the application starts
HAEApplication.getInstance().setAccessToken("your access token");
- 1.
- adopt setApiKey Method setting api_key, You can initialize the settings once when the application starts , There is no need to set it more than once .
- 1.
HAEApplication.getInstance().setApiKey("your ApiKey");
2.2 Initialization environment
Initialize the audio editing management class 、 Create a timeline and the required lanes .
// Create audio editing management class
HuaweiAudioEditor mEditor = HuaweiAudioEditor.create(mContext);
// initialization Editor Operating environment
mEditor.initEnvironment();
// Create a timeline
HAETimeLine mTimeLine = mEditor.getTimeLine();
// Create Lane
HAEAudioLane audioLane = mTimeLine.appendAudioLane();
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
Import music .
// Add audio resources at the end of the lane
HAEAudioAsset audioAsset = audioLane.appendAudioAsset("/sdcard/download/test.mp3", mTimeLine.getCurrentTime());
- 1.
- 2.
3. AI Dubbing function integration
call HAEAiDubbingEngine Realization AI Dubbing function .
// Use this configuration class to configure AI Configure the dubbing engine
HAEAiDubbingConfig haeAiDubbingConfig = new HAEAiDubbingConfig()
// set volume
.setVolume(volumeVal)
// Set the speed of sound
.setSpeed(speedVal)
// Set the speaker
.setType(defaultSpeakerType);
// Single AI Dubbing task callback
HAEAiDubbingCallback callback = new HAEAiDubbingCallback() {
@Override
public void onError(String taskId, HAEAiDubbingError err) {
// error Handle
}
@Override
public void onWarn(String taskId, HAEAiDubbingWarn warn) {}
@Override
public void onRangeStart(String taskId, int start, int end) {}
@Override
public void onAudioAvailable(String taskId, HAEAiDubbingAudioInfo haeAiDubbingAudioFragment, int i, Pair<Integer, Integer> pair, Bundle bundle) {
// Start receiving files , Save as file
}
@Override
public void onEvent(String taskId, int eventID, Bundle bundle) {
// The synthesis is complete.
if (eventID == HAEAiDubbingConstants.EVENT_SYNTHESIS_COMPLETE) {
// AI End of dubbing task processing , That is, all the synthesized audio data are processed
}
}
@Override
public void onSpeakerUpdate(List<HAEAiDubbingSpeaker> speakerList, List<String> lanList,
List<String> lanDescList) { }
};
// AI Dubbing engine
HAEAiDubbingEngine mHAEAiDubbingEngine = new HAEAiDubbingEngine(haeAiDubbingConfig);
// Set up AI Listen during the playback of dubbing task
mHAEAiDubbingEngine.setAiDubbingCallback(callback);
// real time AI Dubbing and playing API,text Pass in the text of the voice to be transferred ,modeAI Dubbing task playback mode
String taskId = mHAEAiDubbingEngine.speak(text, mode);
// Pause play
mHAEAiDubbingEngine.pause();
// Resume playback
mHAEAiDubbingEngine.resume();
// Turn off synthesis
mHAEAiDubbingEngine.stop();
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
Demo demonstration

< nice to meet you >
More details of Huawei audio editing service , Please refer to : Service website : https://developer.huawei.com/consumer/cn/hms/huawei-audio-editor/?ha_source=hms1 Get guidance documents : https://developer.huawei.com/consumer/cn/doc/development/Media-Guides/client-dev-0000001107465102?ha_source=hms1
Learn more >>
visit Official website of Huawei developer Alliance
obtain Development guidance document
Huawei mobile service open source warehouse address : GitHub、 Gitee
Pay attention to our , The first time to understand HMS Core Latest technical information ~
边栏推荐
- C#的变量
- A method of quickly reusing wechat login authorization in app
- High speed layout guidelines incomplete
- Typescript type declaration file (III)
- Office application cannot start normally 0xc0000142
- HTTP缓存<强缓存与协商缓存>
- 轻量、便捷的小程序转App技术方案,实现与微信/流量App互联互通
- Tutoriel de démarrage rapide JDBC
- Message queuing MySQL tables that store message data
- Queue priority of message queue practice
猜你喜欢

SSM integrates FreeMarker and common syntax

A story on the cloud of the Centennial Olympic Games belonging to Alibaba cloud video cloud

First principles of enterprise architecture

赛程更新| 2022微软与英特尔黑客松大赛火热报名中

vant3+ts+pinia tab选项卡列表页面点击进详情,详情页返回tab高亮在原位置,刷新高亮默认在第一项

小程序+App,低成本获客及活跃的一种技术组合思路

MySQL learning notes
![[csp]202012-2 optimal threshold for period end forecast](/img/40/9b59bd692bcfe05d16614cc6d55d1f.png)
[csp]202012-2 optimal threshold for period end forecast

Advanced mountain -asp Net core router basic use demo 0.1

Small program +app, a low-cost and active technology combination idea
随机推荐
01-复杂度
联想回应笔记本太多太杂乱:现在是产品调整期 未来将分为数字/Air/ Pro三大系列
Write a select based concurrent server
Typescript type declaration file (III)
Typescript advanced type (2)
Leetcode 718 longest common substring
LCD parameter interpretation and calculation
es7不使用父子和嵌套关系来实现一对多功能
JS sum of two numbers
有源差分晶振原理图以及LV-PECL、LVDS、HCSL区别
Still using Microsoft office, 3 fairy software, are you sure you don't want to try?
566. reshaping the matrix
Authorization in Golang ProjectUseing Casbin
Schematic diagram of active differential crystal oscillator and differences among lv-pecl, LVDS and HCSL
vant3+ts 封装uploader上传图片组件
Lenovo responded that there are too many and too messy notebooks: it is now the product adjustment period and will be divided into three series of digital /air/ pro in the future
网盘和对象云存储管理之磁盘映射工具比较
The server time zone value ‘� й ��� ʱ ��‘ is unrecognized or represents more than one time zone. ......
Is it safe to open an account in flush
Stack in JS (including leetcode examples) < continuous update ~>