update:上报聊天音频

This commit is contained in:
hrz
2025-05-02 16:17:18 +08:00
parent bf08a91191
commit dfb2bf3923
6 changed files with 71 additions and 24 deletions
@@ -177,5 +177,5 @@ public interface Constant {
/**
* 版本号
*/
public static final String VERSION = "0.3.13";
public static final String VERSION = "0.3.14";
}
@@ -26,6 +26,6 @@ public class AgentChatHistoryReportDTO {
@Schema(description = "聊天内容", example = "你好呀")
@NotBlank
private String content;
@Schema(description = "文件数据(opus编码)", example = "")
private String opusDataBase64;
@Schema(description = "base64编码的opus音频数据", example = "")
private String audioBase64;
}
@@ -1,5 +1,7 @@
package xiaozhi.modules.agent.service.biz.impl;
import java.util.Base64;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -43,12 +45,11 @@ public class AgentChatHistoryBizServiceImpl implements AgentChatHistoryBizServic
// 1. base64解码report.getOpusDataBase64(),存入ai_agent_chat_audio表
String audioId = null;
if (report.getOpusDataBase64() != null && !report.getOpusDataBase64().isEmpty()) {
if (report.getAudioBase64() != null && !report.getAudioBase64().isEmpty()) {
try {
// TODO: 需要考虑保留什么格式的音频数据,比如是opus还是wave
// byte[] audioData = Base64.getDecoder().decode(report.getOpusDataBase64());
// audioId = agentChatAudioService.saveAudio(audioData);
// log.info("音频数据保存成功,audioId={}", audioId);
byte[] audioData = Base64.getDecoder().decode(report.getAudioBase64());
audioId = agentChatAudioService.saveAudio(audioData);
log.info("音频数据保存成功,audioId={}", audioId);
} catch (Exception e) {
log.error("音频数据保存失败", e);
return false;