音频模型调整

This commit is contained in:
spllzh
2025-10-21 09:23:23 +08:00
parent a029d57e7d
commit 9aba49a817
25 changed files with 254 additions and 4 deletions

View File

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rj.entity.TtsRequestLog;
import com.rj.mapper.TtsRequestLogMapper;
import com.rj.service.ITtsRequestLogService;
import com.rj.dto.AsrRequest;
import com.rj.dto.AsrResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -13,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
@@ -40,6 +41,7 @@ public class TtsRequestLogController {
public ResponseEntity<Map<String, Object>> getTtsRequestLogs(
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer pageNum,
@Parameter(description = "每页大小") @RequestParam(defaultValue = "10") Integer pageSize,
@Parameter(description = "音乐名称") @RequestParam(required = false) String audioName,
@Parameter(description = "状态") @RequestParam(required = false) String status,
@Parameter(description = "模型") @RequestParam(required = false) String model,
@Parameter(description = "创建人姓名") @RequestParam(required = false) String creatorName,
@@ -48,12 +50,15 @@ public class TtsRequestLogController {
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime) {
Map<String, Object> result = new HashMap<>();
try {
Page<TtsRequestLog> page = new Page<>(pageNum, pageSize);
QueryWrapper<TtsRequestLog> queryWrapper = new QueryWrapper<>();
// 添加查询条件
if (audioName != null && !audioName.trim().isEmpty()) {
queryWrapper.like("audio_name", audioName);
}
if (status != null && !status.trim().isEmpty()) {
queryWrapper.eq("status", status);
}
@@ -149,4 +154,28 @@ public class TtsRequestLogController {
return ResponseEntity.status(500).body(result);
}
}
@PostMapping("/speech-to-text")
@Operation(summary = "语音转文本", description = "将语音文件转换为文本")
public ResponseEntity<AsrResponse> speechToText(
@Parameter(description = "语音转文本请求参数") @RequestBody AsrRequest request) {
try {
if (!ttsRequestLogService.isAsrServiceAvailable()) {
return ResponseEntity.status(500).body(AsrResponse.error("ASR服务不可用请检查配置"));
}
AsrResponse response = ttsRequestLogService.speechToText(request);
if (response.isSuccess()) {
return ResponseEntity.ok(response);
} else {
return ResponseEntity.status(500).body(response);
}
} catch (Exception e) {
log.error("语音转文本失败: {}", e.getMessage(), e);
return ResponseEntity.status(500).body(AsrResponse.error("语音转文本失败: " + e.getMessage()));
}
}
}