|
|
@@ -190,19 +190,22 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
|
|
|
// 1.2 校验模型
|
|
|
AiModelDO model = modalService.validateModel(conversation.getModelId());
|
|
|
StreamingChatModel chatModel = modalService.getChatModel(model.getId());
|
|
|
+ // 仅在请求开启音频播放时,才查询并初始化 TTS 相关配置和服务。
|
|
|
+ boolean playAudio = Boolean.TRUE.equals(sendReqVO.getPlayAudio());
|
|
|
+
|
|
|
//角色
|
|
|
AiChatRoleDO chatRole = null;
|
|
|
- if (conversation.getRoleId() != null) {
|
|
|
+ if (playAudio && conversation.getRoleId() != null) {
|
|
|
chatRole = chatRoleService.getChatRole(conversation.getRoleId());
|
|
|
}
|
|
|
//发声人
|
|
|
AiTtsDO aiTtsDO = null;
|
|
|
- if (chatRole != null) {
|
|
|
+ if (chatRole != null && chatRole.getTtsId() != null) {
|
|
|
aiTtsDO = ttsMapper.selectById(chatRole.getTtsId());
|
|
|
}
|
|
|
|
|
|
// 添加useTts标志,判断是否使用TTS服务
|
|
|
- boolean useTts = aiTtsDO != null;
|
|
|
+ boolean useTts = playAudio && aiTtsDO != null;
|
|
|
// 创建final副本供lambda表达式使用
|
|
|
final boolean finalUseTts = useTts;
|
|
|
final AiTtsDO finalAiTtsDO = aiTtsDO;
|
|
|
@@ -802,4 +805,4 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
|
|
|
return chatMessageMapper.selectPage(pageReqVO);
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|