feat: 功能优化

This commit is contained in:
2026-02-01 21:11:29 +08:00
parent 808774c333
commit ca82e41674
8 changed files with 33 additions and 41 deletions

View File

@@ -57,6 +57,15 @@ public class CosyVoiceClient {
if (!config.isEnabled()) {
throw exception0(VOICE_TTS_FAILED.getCode(), "未配置 CosyVoice API Key");
}
// 添加详细的参数检查日志
String text = request != null ? request.getText() : null;
log.error("[CosyVoice][TTS参数检查][request={}, text={}, voiceId={}, model={}]",
request != null ? "存在" : "为null",
text != null ? "'" + text + "' (长度:" + text.length() + ")" : "为null",
request != null ? request.getVoiceId() : null,
request != null ? request.getModel() : null);
if (request == null || StrUtil.isBlank(request.getText())) {
throw exception0(VOICE_TTS_FAILED.getCode(), "TTS 文本不能为空");
}
@@ -86,7 +95,9 @@ public class CosyVoiceClient {
if (StrUtil.isNotBlank(request.getInstruction())) {
param.setInstruction(request.getInstruction());
}
log.error("[CosyVoice][SDK参数][param={}, text='{}']", param, request.getText());
// 初始化合成器(同步调用传 null
synthesizer = new SpeechSynthesizer(param, null);

View File

@@ -92,6 +92,9 @@ public class CosyVoiceProvider implements VoiceCloneProvider {
.preview(request.isPreview())
.build();
log.error("[CosyVoiceProvider][构建的cosyRequest][text='{}', voiceId={}, fileUrl={}]",
cosyRequest.getText(), cosyRequest.getVoiceId(), cosyRequest.getFileUrl());
// 调用底层 Client
cn.iocoder.yudao.module.tik.voice.client.dto.CosyVoiceTtsResult cosyResult =
cosyVoiceClient.synthesize(cosyRequest);

View File

@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.tik.voice.client.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;
@@ -20,8 +21,9 @@ public class SiliconFlowTtsRequest {
private String model;
/**
* 待合成文本
* 待合成文本API 参数名text
*/
@JsonProperty("text")
private String input;
/**
@@ -37,11 +39,13 @@ public class SiliconFlowTtsRequest {
/**
* 采样率(如 24000
*/
@JsonProperty("sample_rate")
private Integer sampleRate;
/**
* 响应格式mp3, wav, pcm
* 响应格式mp3, wav, pcmAPI 参数名format
*/
@JsonProperty("format")
private String responseFormat;
}