阿里云声音复刻
个性化人声定制
阿里云个性化人声定制是智能语音交互产品自学习平台下的一部分
使用方式:https://help.aliyun.com/document_detail/456006.html
-
方式一:控制台界面定制使用方式
-
方式二:通过OpenAPI定制:在该页面有不同开发语言的示例代码,开发者使用openAPI概览注意只有四个API方法和声音克隆的API方法有所不同
Java示例代码
package com.alibaba.nls.ptts;import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.http.ProtocolType;
import com.aliyuncs.profile.DefaultProfile;public class PttsDemo {//域名private static final String DOMAIN = "nls-measure.cn-shanghai.aliyuncs.com";// API版本private static final String API_VERSION = "2019-09-05";private static IAcsClient client;static {String accessKeyId = "请替换为您自己的accessKeyId";String accessKeySecret = "请替换为您自己的accessKeySecret";// 创建DefaultAcsClient实例并初始化DefaultProfile profile = DefaultProfile.getProfile("",accessKeyId,accessKeySecret);client = new DefaultAcsClient(profile);}public static void main(String[] args) throws InterruptedException {//20句音频,此处为了方便演示接口的调用,提前准备好了音频的url,在您集成时,可以在用户录制的过程中,将音频进行存储String[] urls = {"viwf/1.wav", "dycw/2.wav", "dopl/3.wav", "anfd/4.wav", "cyoy/5.wav", "dsjw/6.wav","vevd/7.wav", "ulno/8.wav", "kwlw/9.wav", "lafu/10.wav", "uozh/11.wav", "gdpp/12.wav", "lisa/13.wav","bmvv/14.wav", "ijzx/15.wav", "kdla/16.wav", "govf/17.wav", "kcid/18.wav", "srdx/19.wav", "stol/20.wav"};//训练的基本信息,voiceName请替换成您自己的命名String voiceName = "示例voice";String scenario = "story";String gender = "female";//Step1: 获取需要朗读的文本CommonRequest getDemonstrationRequest = buildRequest("GetDemonstrationForCustomizedVoice");getDemonstrationRequest.putQueryParameter("Scenario", scenario);String getDemonstrationResponse = sendRequest(getDemonstrationRequest);System.out.println("|获取需要朗读的内容|response=" + getDemonstrationResponse);//Step2: 采集用户朗读的音频,进行音频检测for (int i = 1; i <= 20; i++) {String audioUrl = audioRecordUrlPrefix + urls[i - 1];CommonRequest audioDetectRequest = buildRequest("CustomizedVoiceAudioDetect");audioDetectRequest.putQueryParameter("Scenario", scenario);audioDetectRequest.putQueryParameter("VoiceName", voiceName);audioDetectRequest.putQueryParameter("RecordUrl", audioUrl);audioDetectRequest.putQueryParameter("AudioRecordId", String.valueOf(i));String audioDetectResponse = sendRequest(audioDetectRequest);System.out.println("|音频检测|[" + i + "]response=" + audioDetectResponse);}//Step3: 20句音频检测完成后,提交训练CommonRequest submitTrainRequest = buildRequest("SubmitCustomizedVoice");submitTrainRequest.putQueryParameter("VoiceName", voiceName);submitTrainRequest.putQueryParameter("Gender", gender);submitTrainRequest.putQueryParameter("Scenario", scenario);String submitTrainResponse = sendRequest(submitTrainRequest);System.out.println("|提交训练|response=" + submitTrainResponse);//Step4: 轮询训练结果CommonRequest queryTrainResultRequest = buildRequest("ListCustomizedVoice");queryTrainResultRequest.putQueryParameter("VoiceName", voiceName);String queryTrainResultResponse = sendRequest(queryTrainResultRequest);System.out.println("|查询训练结果|response=" + queryTrainResultResponse);}private static String audioRecordUrlPrefix= "https://static-aliyun-doc.oss-cn-hangzhou.aliyuncs.com/file-manage-files/zh-CN/20221118/";private static CommonRequest buildRequest(String popApiName) {CommonRequest request = new CommonRequest();request.setSysMethod(MethodType.POST);request.setSysDomain(DOMAIN);request.setSysVersion(API_VERSION);request.setSysAction(popApiName);request.setSysProtocol(ProtocolType.HTTPS);return request;}private static String sendRequest(CommonRequest request) {try {CommonResponse response = client.getCommonResponse(request);return response.getData();} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {e.printStackTrace();}return null;}
}
阿里云个人化人声定制控制台
https://nls-portal.console.aliyun.com/pttssettingnew
非开发者使用指南:
https://help.aliyun.com/document_detail/451766.html?spm=a2c4g.432038.0.0.496f4906w8EQFD
声音克隆定制
阿里云产品帮助中心搜索声音克隆https://help.aliyun.com/?spm=a2c4g.456006.J_3207526240.2.6a5842e8QI7zZj
方法一:通过控制台进行人声克隆
- 登录智能媒体服务控制台。
- 在顶部左上角根据实际情况选择地域。
- 在左侧导航栏选择****智能生产制作** > *人声克隆***。
- 单击定制声音,根据提示完成定制人声操作。
方法二:通过OpenAPI进行人声克隆
-
调用接口CreateCustomizedVoiceJob,配置参数
VoiceId
,创建人声克隆任务。 -
调用接口GetDemonstrationForCustomizedVoiceJob,根据实际场景配置参数
Scenario
,获取需要朗读的20条示范文本及音频。 -
根据步骤 2获取到的示范文本及音频进行训练并录制,并将录制的语音上传至OSS。上传方式,请参见上传文件。
-
调用接口DetectAudioForCustomizedVoiceJob,提交已经训练好的音频,进行音频检测。
重要 需要调用20次该接口,每次调用时提交对应的音频,共20条音频。
-
调用接口SubmitCustomizedVoiceJob,提交人声克隆训练任务,系统开始进行语音训练。
API参考
人声克隆相关接口
openApI门户:https://next.api.aliyun.com/api/ICE/2020-11-09/CreateCustomizedVoiceJob?tab=DEMO&lang=JAVA
SDK开发包使用方法:https://help.aliyun.com/document_detail/262200.html?spm=a2c4g.378655.0.0.534f5068p0WEYq
运行实例注意区分SDK版本