|
|
|
@ -34,7 +34,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService { |
|
|
|
private IAppletTtsPlayLogService appletTtsPlayLogService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public String textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec) { |
|
|
|
public TextToVoiceResponse textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec) { |
|
|
|
return textToVoice(text, speed, voiceType, volume, codec, null); |
|
|
|
} |
|
|
|
|
|
|
|
@ -127,7 +127,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService { |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
public String textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec, String userId) { |
|
|
|
public TextToVoiceResponse textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec, String userId) { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
try { |
|
|
|
@ -172,6 +172,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService { |
|
|
|
req.setModelType(1L); // 默认模型 |
|
|
|
req.setPrimaryLanguage(2L); // 中文 |
|
|
|
req.setSampleRate(16000L); // 16k采样率 |
|
|
|
req.setEnableSubtitle(true); |
|
|
|
|
|
|
|
// 返回的resp是一个TextToVoiceResponse的实例,与请求对象对应 |
|
|
|
TextToVoiceResponse resp = client.TextToVoice(req); |
|
|
|
@ -189,7 +190,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService { |
|
|
|
speed != null ? speed.doubleValue() : null, elapsedTime, true); |
|
|
|
|
|
|
|
log.info("TTS调用成功,文本长度: {}, 耗时: {}秒", text != null ? text.length() : 0, elapsedTime); |
|
|
|
return audioBase64; |
|
|
|
return resp; |
|
|
|
} else { |
|
|
|
// 记录失败的TTS调用日志 |
|
|
|
savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null, |
|
|
|
|