From 61d959e6b80142d3dd9afd1b9cd05f325a001f0a Mon Sep 17 00:00:00 2001 From: wangxiangshun Date: Fri, 7 Nov 2025 09:57:49 +0800 Subject: [PATCH] =?UTF-8?q?TTS=20key=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vetti/socket/ChatWebSocketHandler.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java b/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java index b410fb0..5f48feb 100644 --- a/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java +++ b/vetti-admin/src/main/java/com/vetti/socket/ChatWebSocketHandler.java @@ -375,6 +375,17 @@ public class ChatWebSocketHandler { //直接对该问题进行转换处理返回语音流 log.info("第一个问题为:{}",question); sendTTSBuffer(clientId, question, session); + //发送问题文本 + try { + //把文本也给前端返回去 + Map 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("type", "score"); try{ + //返回评分语音 + sendTTSBuffer(clientId,resultMsg,session); + //返回最终的评分结构 log.info("返回最终的评分结构:{}",JSONUtil.toJsonStr(resultEntity)); session.getBasicRemote().sendText(JSONUtil.toJsonStr(resultEntity)); - //返回评分语音 - sendTTSBuffer(clientId,resultMsg,session); - }catch (Exception e){ e.printStackTrace(); } @@ -544,6 +555,9 @@ public class ChatWebSocketHandler { String openingPathUrl = RuoYiConfig.getProfile() + VOICE_SYSTEM_DIR + "end.wav"; sendVoiceBuffer(openingPathUrl, session); + //返回评分语音 + sendTTSBuffer(clientId,scoreText,session); + Map resultEntity = new HashMap<>(); resultEntity.put("content", scoreText); resultEntity.put("type", "score"); @@ -551,9 +565,6 @@ public class ChatWebSocketHandler { log.info("返回最终的评分结果:{}",JSONUtil.toJsonStr(resultEntity)); session.getBasicRemote().sendText(JSONUtil.toJsonStr(resultEntity)); - //返回评分语音 - sendTTSBuffer(clientId,scoreText,session); - } } catch (Exception e) { e.printStackTrace();