TTS 返回语音优化

This commit is contained in:
2025-10-19 18:35:54 +08:00
parent a3ef5d1959
commit a839571b4e
4 changed files with 66 additions and 18 deletions

View File

@@ -115,21 +115,22 @@ public class OpenAiStreamClient {
.getJSONObject("delta")
.getStr("content");
if (content != null && !content.isEmpty()) {
if(punctuationSet.contains(content)){
//说明有标点啦,直接返回
bufferStr.append(content);
listener.onMessage(bufferStr.toString());
}else{
//加入缓冲区
if(StrUtil.isEmpty(bufferStr.toString())){
bufferStr.append(content);
}else {
bufferStr.append(" ").append(content);
}
}
}
// if (content != null && !content.isEmpty()) {
// if(punctuationSet.contains(content)){
// //说明有标点啦,直接返回
// bufferStr.append(content);
// listener.onMessage(bufferStr.toString());
// }else{
// //加入缓冲区
// if(StrUtil.isEmpty(bufferStr.toString())){
// bufferStr.append(content);
// }else {
// bufferStr.append(" ").append(content);
// }
// }
//
// }
listener.onMessage(content);
} catch (Exception e) {
listener.onError(new IOException("Parse error: " + e.getMessage()));
}