前端-胡立永 1 month ago
parent
commit
cb078f9891
4 changed files with 10 additions and 16 deletions
  1. +3
    -2
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiTTSController.java
  2. +3
    -2
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiTTService.java
  3. +4
    -3
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiTTServiceImpl.java
  4. +0
    -9
      jeecg-boot/jeecg-boot-module/module-pay/src/main/java/org/jeecg/modules/pay/config/WxPay.java

+ 3
- 2
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiTTSController.java View File

@ -1,6 +1,7 @@
package org.jeecg.modules.applet.controller; package org.jeecg.modules.applet.controller;
import com.tencentcloudapi.tts.v20190823.models.TextToVoiceResponse;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -77,7 +78,7 @@ public class AppletApiTTSController {
// return ResponseEntity.internalServerError().build(); // return ResponseEntity.internalServerError().build();
// } // }
// } // }
public Result textToVoice(
public Result<TextToVoiceResponse> textToVoice(
@Parameter(description = "要转换的文本内容", required = true) String text, @Parameter(description = "要转换的文本内容", required = true) String text,
@Parameter(description = "语速,范围:[-2,6],默认为0-2代表0.6倍\n" + @Parameter(description = "语速,范围:[-2,6],默认为0-2代表0.6倍\n" +
"-1代表0.8倍\n" + "-1代表0.8倍\n" +
@ -89,7 +90,7 @@ public class AppletApiTTSController {
@Parameter(description = "音量大小,范围[-10,10],默认为0") Float volume, @Parameter(description = "音量大小,范围[-10,10],默认为0") Float volume,
@Parameter(description = "返回音频格式,可取值:wav(默认),mp3,pcm") String codec) { @Parameter(description = "返回音频格式,可取值:wav(默认),mp3,pcm") String codec) {
String audioData = appletApiTTService.textToVoice(text, speed, voiceType, volume, codec);
TextToVoiceResponse audioData = appletApiTTService.textToVoice(text, speed, voiceType, volume, codec);
return Result.ok(audioData); return Result.ok(audioData);
} }


+ 3
- 2
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiTTService.java View File

@ -1,5 +1,6 @@
package org.jeecg.modules.applet.service; package org.jeecg.modules.applet.service;
import com.tencentcloudapi.tts.v20190823.models.TextToVoiceResponse;
import org.jeecg.modules.demo.appletTtsTimbre.entity.AppletTtsTimbre; import org.jeecg.modules.demo.appletTtsTimbre.entity.AppletTtsTimbre;
import java.util.List; import java.util.List;
@ -14,7 +15,7 @@ public interface AppletApiTTService {
* @param codec 返回音频格式可取值wav默认mp3pcm * @param codec 返回音频格式可取值wav默认mp3pcm
* @return 音频二进制数据 * @return 音频二进制数据
*/ */
String textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec);
TextToVoiceResponse textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec);
/** /**
* 文字转语音带用户ID记录日志 * 文字转语音带用户ID记录日志
@ -26,7 +27,7 @@ public interface AppletApiTTService {
* @param userId 用户ID用于记录日志 * @param userId 用户ID用于记录日志
* @return 音频二进制数据 * @return 音频二进制数据
*/ */
String textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec, String userId);
TextToVoiceResponse textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec, String userId);
List<AppletTtsTimbre> list(); List<AppletTtsTimbre> list();
} }

+ 4
- 3
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiTTServiceImpl.java View File

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


+ 0
- 9
jeecg-boot/jeecg-boot-module/module-pay/src/main/java/org/jeecg/modules/pay/config/WxPay.java View File

@ -67,13 +67,4 @@ public class WxPay {
*/ */
public String notifyOrderUrlDev; public String notifyOrderUrlDev;
} }

Loading…
Cancel
Save