TTS key 修改

This commit is contained in:
2025-11-07 09:57:49 +08:00
parent 17cda288a3
commit 61d959e6b8

View File

@@ -375,6 +375,17 @@ public class ChatWebSocketHandler {
//直接对该问题进行转换处理返回语音流 //直接对该问题进行转换处理返回语音流
log.info("第一个问题为:{}",question); log.info("第一个问题为:{}",question);
sendTTSBuffer(clientId, question, session); sendTTSBuffer(clientId, question, session);
//发送问题文本
try {
//把文本也给前端返回去
Map<String, String> dataText = new HashMap<>();
dataText.put("type", "question");
dataText.put("content", question);
log.info("提问的问题文本发送啦:{}",JSONUtil.toJsonStr(dataText));
session.getBasicRemote().sendText(JSONUtil.toJsonStr(dataText));
} catch (Exception e) {
e.printStackTrace();
}
} }
} }
//初始化记录提示词数据到-缓存中 //初始化记录提示词数据到-缓存中
@@ -429,13 +440,13 @@ public class ChatWebSocketHandler {
resultEntity.put("content", resultMsg); resultEntity.put("content", resultMsg);
resultEntity.put("type", "score"); resultEntity.put("type", "score");
try{ try{
//返回评分语音
sendTTSBuffer(clientId,resultMsg,session);
//返回最终的评分结构 //返回最终的评分结构
log.info("返回最终的评分结构:{}",JSONUtil.toJsonStr(resultEntity)); log.info("返回最终的评分结构:{}",JSONUtil.toJsonStr(resultEntity));
session.getBasicRemote().sendText(JSONUtil.toJsonStr(resultEntity)); session.getBasicRemote().sendText(JSONUtil.toJsonStr(resultEntity));
//返回评分语音
sendTTSBuffer(clientId,resultMsg,session);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@@ -544,6 +555,9 @@ public class ChatWebSocketHandler {
String openingPathUrl = RuoYiConfig.getProfile() + VOICE_SYSTEM_DIR + "end.wav"; String openingPathUrl = RuoYiConfig.getProfile() + VOICE_SYSTEM_DIR + "end.wav";
sendVoiceBuffer(openingPathUrl, session); sendVoiceBuffer(openingPathUrl, session);
//返回评分语音
sendTTSBuffer(clientId,scoreText,session);
Map<String, String> resultEntity = new HashMap<>(); Map<String, String> resultEntity = new HashMap<>();
resultEntity.put("content", scoreText); resultEntity.put("content", scoreText);
resultEntity.put("type", "score"); resultEntity.put("type", "score");
@@ -551,9 +565,6 @@ public class ChatWebSocketHandler {
log.info("返回最终的评分结果:{}",JSONUtil.toJsonStr(resultEntity)); log.info("返回最终的评分结果:{}",JSONUtil.toJsonStr(resultEntity));
session.getBasicRemote().sendText(JSONUtil.toJsonStr(resultEntity)); session.getBasicRemote().sendText(JSONUtil.toJsonStr(resultEntity));
//返回评分语音
sendTTSBuffer(clientId,scoreText,session);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();