当前位置:网站首页>The song of the virtual idol was originally generated in this way!
The song of the virtual idol was originally generated in this way!
2022-07-29 04:55:00 【nginx】

Voice synthesis services can be widely used in Creative production of audio and video 、 Video entertainment 、 music education 、 Virtual idol Other fields . for example , In music creation or short video creative editing , The song synthesis service can help users create and synthesize songs freely , Make the creation more colorful . In the field of virtual idols , Through singing synthesis , It can make virtual people have the ability to sing in a specific timbre , Make it more vivid . In music games or Singing Education , Song synthesis can quickly generate standard reference sound , Improve the efficiency of audio production and save labor costs .
Song synthesis effect
Heard the singing synthesis comparable to the singing effect of real people , Can't wait to use it , The following is the specific integration method of song synthesis . Come and try the integration yourself !
1. The development of preparation
1.1 Register as a developer
Before developing an application, you need to register as a developer on the Huawei developer alliance website and complete real name authentication , Please refer to account registration certification for specific methods .
1.2 Create projects and applications
See create project , Then create an application under the project to complete the creation of the application , Special configurations are as follows :
Selection platform : choice “Web”.
1.3 Open related services
Use Audio Editor Kit Service requires you to AppGallery Connect Open up Audio Editor Kit Service switch , Please refer to turning on the service switch .
2. Song synthesis function integration
2.1 Synchronization interface ( streaming )
2.1.1 obtain access_token Authentication information
The client obtained by using the developer alliance interface ID And the corresponding key , send out HTTPS POST request , Get query access_token. Please refer to client mode (Client Credentials).
2.1.2 according to access_token Call synchronization interface ( streaming )
Obtained through the above steps access_token Information , send out HTTPS POST Call synchronization interface ( streaming ).
Sample code ( java) As shown below :
among requestUrl = "https://audioeditor-api-drcn.cloud.huawei.com/v1/audioeditor/gateway/ai/ttsing/sync".
2.2 Asynchronous interface
/*** Call synchronization interface ( streaming )* @param accessToken according to clientId And key acquisition token* @throws Exception IO abnormal*/private static void syncTask(String accessToken) throws Exception {// Set the request headerPostMethod postMethod = new PostMethod(requestUrl);postMethod.setRequestHeader("Content-Type","application/json;charset=utf-8");postMethod.setRequestHeader("X-Request-ID","9af1aeda-531b-407a-80b4-65b40ef77bd6");postMethod.setRequestHeader("X-Package-Name","com.huawei.demo");postMethod.setRequestHeader("X-Country-Code","cn");postMethod.setRequestHeader("HMS-APPLICATION-ID","123456");postMethod.setRequestHeader("certFingerprint","xxxxx");postMethod.setRequestHeader("Authorization","Bearer " + accessToken);// Set the request bodyMap<String, Object> bodyMap = new HashMap<>();Map<String, Object> dataMap = new HashMap<>();Map<String, Object> configMap = new HashMap<>();// filePath yes MusicXML File path ( Include file name 、 suffix )String lyricFilePath = "filePath";dataMap.put("lyric", FileUtils.readFileToString(new File(lyricFilePath), "UTF-8"));dataMap.put("language", "chinese");configMap.put("type", 1);configMap.put("outputEncoderFormat", 0);bodyMap.put("data", dataMap);bodyMap.put("config", configMap);RequestEntity requestEntity = new StringRequestEntity(JSONObject.toJSONString(bodyMap),"application/json" ,"UTF-8");postMethod.setRequestEntity(requestEntity);HttpClient httpClient = new HttpClient();int ret = httpClient.executeMethod(postMethod);if (ret == 200) {Header responseHeader = postMethod.getResponseHeader("content-type");if ("application/octet-stream".equals(responseHeader.getValue())) {InputStream rpsContent = postMethod.getResponseBodyAsStream();// filePath Is the path to save the file ( Include file name 、 suffix )String filePath = "filePath";FileUtils.copyInputStreamToFile(rpsContent, new File(filePath));} else {String errorString = postMethod.getResponseBodyAsString();System.out.println(errorString);}} else {System.out.println("callApi failed: ret =" + ret + " rsp=" + postMethod.getResponseBodyAsString());}}
2.2.1 Create asynchronous tasks
adopt access_token Information , send out HTTPS POST Create song synthesis asynchronous task .
2.2.2 Query asynchronous task status
/*** Call to create an asynchronous task interface* @param accessToken according to clientId And key acquisition token* @throws Exception IO abnormal*/private static void creatAsyncTask(String accessToken) throws Exception {// Set the request headerPostMethod postMethod = new PostMethod(requestUrl);postMethod.setRequestHeader("Content-Type","application/json;charset=utf-8");postMethod.setRequestHeader("X-Request-ID","9af1aeda-531b-407a-80b4-65b40ef77bd6");postMethod.setRequestHeader("X-Package-Name","com.huawei.demo");postMethod.setRequestHeader("X-Country-Code","cn");postMethod.setRequestHeader("HMS-APPLICATION-ID","123456");postMethod.setRequestHeader("certFingerprint","xxxxx");postMethod.setRequestHeader("Authorization","Bearer " + accessToken);// Set the request bodyMap<String, Object> bodyMap = new HashMap<>();Map<String, Object> dataMap = new HashMap<>();Map<String, Object> configMap = new HashMap<>();// filePath yes MusicXML File path ( Include file name 、 suffix )String lyricFilePath = "filePath";dataMap.put("lyric", FileUtils.readFileToString(new File(lyricFilePath), "UTF-8"));dataMap.put("language", "chinese");configMap.put("type", 1);configMap.put("outputEncoderFormat", 0);bodyMap.put("data", dataMap);bodyMap.put("config", configMap);RequestEntity requestEntity = new StringRequestEntity(JSONObject.toJSONString(bodyMap),"application/json" ,"UTF-8");postMethod.setRequestEntity(requestEntity);HttpClient httpClient = new HttpClient();int ret = httpClient.executeMethod(postMethod);String rpsContent = postMethod.getResponseBodyAsString();if (ret == 200) {System.out.println(rpsContent);} else {System.out.println("callApi failed: ret =" + ret + " rsp=" + rpsContent);}}
adopt access_token Information , send out HTTPS POST Query song synthesis asynchronous task status .
2.2.3 Cancel asynchronous task
/*** Call the interface for querying asynchronous task status* @param accessToken according to clientId And key acquisition token* @throws Exception IO abnormal*/private static void queryAsyncTaskInfo(String accessToken) throws Exception {// Set the request headerPostMethod postMethod = new PostMethod(requestUrl);postMethod.setRequestHeader("Content-Type","application/json;charset=utf-8");postMethod.setRequestHeader("X-Request-ID","9af1aeda-531b-407a-80b4-65b40ef77bd6");postMethod.setRequestHeader("X-Package-Name","com.huawei.demo");postMethod.setRequestHeader("X-Country-Code","cn");postMethod.setRequestHeader("HMS-APPLICATION-ID","123456");postMethod.setRequestHeader("certFingerprint","xxxxx");postMethod.setRequestHeader("Authorization","Bearer " + accessToken);// Set the request bodyMap<String, Object> bodyMap = new HashMap<>();// taskId The corresponding value is the task returned when creating the asynchronous task ID(taskId)bodyMap.put("taskId", "taskId");RequestEntity requestEntity = new StringRequestEntity(JSONObject.toJSONString(bodyMap),"application/json" ,"UTF-8");postMethod.setRequestEntity(requestEntity);HttpClient httpClient = new HttpClient();int ret = httpClient.executeMethod(postMethod);String rpsContent = postMethod.getResponseBodyAsString();if (ret == 200) {System.out.println(rpsContent);} else {System.out.println("callApi failed: ret =" + ret + " rsp=" + rpsContent);}}
adopt access_token Information , send out HTTPS POST Cancel asynchronous task .
In addition to the ability to synthesize songs , The audio editing service also provides basic audio editing 、AI Dubbing accompaniment extraction 、 Spatial rendering 、 Rich audio processing capabilities such as variable sound and noise reduction , Provide excellent performance for developers around the world 、 Simple and easy to use 、 An open interface , Help developers easily and efficiently build application audio editing capabilities .
/*** Call to cancel the asynchronous task interface* @param accessToken according to clientId And key acquisition token* @throws Exception IO abnormal*/private static void cancelAsuncTask(String accessToken) throws Exception {// Set the request headerPostMethod postMethod = new PostMethod(requestUrl);postMethod.setRequestHeader("Content-Type","application/json;charset=utf-8");postMethod.setRequestHeader("X-Request-ID","9af1aeda-531b-407a-80b4-65b40ef77bd6");postMethod.setRequestHeader("X-Package-Name","com.huawei.demo");postMethod.setRequestHeader("X-Country-Code","cn");postMethod.setRequestHeader("HMS-APPLICATION-ID","123456");postMethod.setRequestHeader("certFingerprint","xxxxx");postMethod.setRequestHeader("Authorization","Bearer " + accessToken);// Set the request bodyMap<String, Object> bodyMap = new HashMap<>();// taskId The corresponding value is the task returned when creating the asynchronous task ID(taskId)bodyMap.put("taskId", "taskId");RequestEntity requestEntity = new StringRequestEntity(JSONObject.toJSONString(bodyMap),"application/json" ,"UTF-8");postMethod.setRequestEntity(requestEntity);HttpClient httpClient = new HttpClient();int ret = httpClient.executeMethod(postMethod);String rpsContent = postMethod.getResponseBodyAsString();if (ret == 200) {System.out.println(rpsContent);} else {System.out.println("callApi failed: ret =" + ret + " rsp=" + rpsContent);}}
Learn more >>
Visit the official website of Huawei developer alliance
Get 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 ~
边栏推荐
- Opencv environment construction
- Command line interactive tools (latest version) inquirer practical tutorial
- def fasterrcnn_ resnet50_ FPN () instance test
- leetcode 763. Partition Labels 划分字母区间(中等)
- UE plays video in scene or UMG
- Learn matlab to draw geographical map, line scatter bubble density map
- 钉钉对话框文子转换成图片 不能复制粘贴到文档上
- 常见的限流方式
- 正确的用户拖拽方式
- Makefile+Make基础知识
猜你喜欢
随机推荐
输入的查询SQL语句,是如何执行的?
Sguard64.exe ace guard client exe: frequent disk reading and writing, game jamming, and Solutions
ios面试准备 - 网络篇
SSM integration, addition, deletion, modification and query
OpenCV环境搭建
Makefile+Make基础知识
Makefile+make Basics
< El table column> place multiple pictures
Un7.28: common commands of redis client.
安装spinning up教程里与mujoco对应的gym,报错mjpro150
Flink+iceberg environment construction and production problem handling
学术 | [LaTex]超详细Texlive2022+Tex Studio下载安装配置
1 句代码,搞定 ASP.NET Core 绑定多个源到同一个类
spinning up安装完使用教程测试是否成功,出现Library“GLU“ not found和‘from pyglet.gl import *错误解决办法
JS daily question (12)
excel怎么设置行高和列宽?excel设置行高和列宽的方法
让你的正则表达式可读性提高一百倍
Review key points and data sorting of information metrology in the second semester of 2022 (teacher zhaorongying of Wuhan University)
Improve the readability of your regular expressions a hundred times
How is the entered query SQL statement executed?
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
![[QT learning notes] * insert pictures in the window](/img/72/ecac8fb35a404130ee020db572a4b4.png)







