当前位置:网站首页>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-27 18:41:00 【HMS Core】
HMS Core Audio editing service (Audio Editor Kit)6.6.0 Version Online , New song synthesis ability . Through lyrics and tunes , Combined with different music styles, the machine can also generate highly authentic songs . Support word level input lyrics for phoneme conversion , Generate a song corresponding to the lyrics , Flexible pitch adjustment 、 Gliding 、 Breathing sounds 、 Vibrato and other detailed parameters , Make the song more authentic .

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 .
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 applications, you need to work in Huawei Developer alliance website Register as a developer and complete real name authentication , Please refer to Account registration authentication .
1.2 Create projects and applications
See Create project , Then under the project Create an 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 Turn 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. For the acquisition method, see 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".
/** * 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 header PostMethod 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 body Map<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 Asynchronous interface
2.2.1 Create asynchronous tasks
adopt access_token Information , send out HTTPS POST Create song synthesis asynchronous task .
/** * 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 header PostMethod 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 body Map<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); } }2.2.2 Query asynchronous task status
adopt access_token Information , send out HTTPS POST Query song synthesis asynchronous task status .
/** * 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 header PostMethod 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 body Map<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); } }2.2.3 Cancel asynchronous task
adopt access_token Information , send out HTTPS POST Cancel asynchronous task .
/** * 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 header PostMethod 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 body Map<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); } }In addition to the ability to synthesize songs , Audio editing service It 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 .
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 ~
边栏推荐
猜你喜欢
随机推荐
Uniapp has no effect on the page selector on the app side
2021.7.12 internal and external connection of notes
[MIT 6.S081] Lab 7: Multithreading
Wechat applet obtains openid, sessionkey, unionid
微信小程序获取手机号
Complete set of machine learning classification task effect evaluation indicators (including ROC and AUC)
multi-table query
微信小程序获取openId, sessionKey, unionId
2021.7.22 note constraints
Machine learning -- error caused by only one kind of label data in SVM training set
2021.7.17 notes MySQL other commands
修改input中placeholder样式
Deep learning: a survey of behavior recognition
2021.7.19 notes DML
JDBC learning day1:jdbc
Wechat applet wechat payment overview
Deep learning: installation package records
[mit 6.s081] LEC 9: interrupts notes
Wechat applet obtains mobile number
Solve the problem that reids cannot be accessed by other IPS



![[MIT 6.S081] Lec 9: Interrupts 笔记](/img/b6/a8d39aa7ede4eb1c5a74e6d15b3b1c.png)



![[MIT 6.S081] Lab 7: Multithreading](/img/f4/26e513fb8678a88cfba29c1a636b37.png)

