客户管理功能调整, 音频模型调整
This commit is contained in:
90
src/main/java/com/rj/dto/AsrRequest.java
Normal file
90
src/main/java/com/rj/dto/AsrRequest.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.rj.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 语音转文本请求DTO
|
||||
*
|
||||
* @author rj
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "语音转文本请求参数")
|
||||
public class AsrRequest {
|
||||
|
||||
/**
|
||||
* 音频文件URL
|
||||
*/
|
||||
@NotBlank(message = "音频文件URL不能为空")
|
||||
@Schema(description = "音频文件URL", example = "https://example.com/audio.mp3")
|
||||
private String audioUrl;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
@Schema(description = "ASR模型名称", example = "paraformer-v2")
|
||||
private String model = "paraformer-v2";
|
||||
|
||||
/**
|
||||
* 音频格式
|
||||
*/
|
||||
@Schema(description = "音频格式", example = "wav")
|
||||
private String format = "wav";
|
||||
|
||||
/**
|
||||
* 采样率
|
||||
*/
|
||||
@Schema(description = "采样率", example = "16000")
|
||||
private Integer sampleRate = 16000;
|
||||
|
||||
/**
|
||||
* 是否启用标点符号
|
||||
*/
|
||||
@Schema(description = "是否启用标点符号", example = "true")
|
||||
private Boolean enablePunctuation = true;
|
||||
|
||||
/**
|
||||
* 是否启用数字转换
|
||||
*/
|
||||
@Schema(description = "是否启用数字转换", example = "true")
|
||||
private Boolean enableNumberConversion = true;
|
||||
|
||||
/**
|
||||
* 是否启用说话人分离
|
||||
*/
|
||||
@Schema(description = "是否启用说话人分离", example = "false")
|
||||
private Boolean enableSpeakerDiarization = false;
|
||||
|
||||
/**
|
||||
* 说话人数量
|
||||
*/
|
||||
@Schema(description = "说话人数量", example = "1")
|
||||
private Integer speakerCount = 1;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
@Schema(description = "创建人姓名", example = "张三")
|
||||
private String creatorName;
|
||||
|
||||
/**
|
||||
* 创建人电话
|
||||
*/
|
||||
@Schema(description = "创建人电话", example = "13800138000")
|
||||
private String creatorPhone;
|
||||
|
||||
/**
|
||||
* 音频名称
|
||||
*/
|
||||
@Schema(description = "音频名称", example = "test_audio")
|
||||
private String audioName;
|
||||
|
||||
/**
|
||||
* 关联的TTS请求日志ID
|
||||
*/
|
||||
@Schema(description = "关联的TTS请求日志ID", example = "12345678-1234-1234-1234-123456789012")
|
||||
private String id;
|
||||
}
|
||||
160
src/main/java/com/rj/dto/AsrResponse.java
Normal file
160
src/main/java/com/rj/dto/AsrResponse.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package com.rj.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 语音转文本响应DTO
|
||||
*
|
||||
* @author rj
|
||||
* @date 2025-01-02
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "语音转文本响应结果")
|
||||
public class AsrResponse {
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
@Schema(description = "是否成功")
|
||||
private boolean success;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
@Schema(description = "响应消息")
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 识别结果文本
|
||||
*/
|
||||
@Schema(description = "识别结果文本")
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* 识别结果列表(包含时间戳和说话人信息)
|
||||
*/
|
||||
@Schema(description = "识别结果列表")
|
||||
private List<AsrResult> results;
|
||||
|
||||
/**
|
||||
* 音频时长(秒)
|
||||
*/
|
||||
@Schema(description = "音频时长(秒)")
|
||||
private Double duration;
|
||||
|
||||
/**
|
||||
* 处理时间(毫秒)
|
||||
*/
|
||||
@Schema(description = "处理时间(毫秒)")
|
||||
private Long processingTimeMs;
|
||||
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
@Schema(description = "任务ID")
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 请求ID
|
||||
*/
|
||||
@Schema(description = "请求ID")
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 错误代码
|
||||
*/
|
||||
@Schema(description = "错误代码")
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMessage;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 识别结果详情
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "识别结果详情")
|
||||
public static class AsrResult {
|
||||
|
||||
/**
|
||||
* 开始时间(秒)
|
||||
*/
|
||||
@Schema(description = "开始时间(秒)")
|
||||
private Double startTime;
|
||||
|
||||
/**
|
||||
* 结束时间(秒)
|
||||
*/
|
||||
@Schema(description = "结束时间(秒)")
|
||||
private Double endTime;
|
||||
|
||||
/**
|
||||
* 识别文本
|
||||
*/
|
||||
@Schema(description = "识别文本")
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* 说话人ID
|
||||
*/
|
||||
@Schema(description = "说话人ID")
|
||||
private String speakerId;
|
||||
|
||||
/**
|
||||
* 置信度
|
||||
*/
|
||||
@Schema(description = "置信度")
|
||||
private Double confidence;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建成功响应
|
||||
*/
|
||||
public static AsrResponse success(String text, List<AsrResult> results, Double duration,
|
||||
Long processingTimeMs, String taskId, String requestId) {
|
||||
AsrResponse response = new AsrResponse();
|
||||
response.setSuccess(true);
|
||||
response.setMessage("语音识别成功");
|
||||
response.setText(text);
|
||||
response.setResults(results);
|
||||
response.setDuration(duration);
|
||||
response.setProcessingTimeMs(processingTimeMs);
|
||||
response.setTaskId(taskId);
|
||||
response.setRequestId(requestId);
|
||||
response.setCreateTime(LocalDateTime.now());
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建错误响应
|
||||
*/
|
||||
public static AsrResponse error(String message) {
|
||||
return error(message, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建错误响应
|
||||
*/
|
||||
public static AsrResponse error(String message, String errorCode, String errorMessage) {
|
||||
AsrResponse response = new AsrResponse();
|
||||
response.setSuccess(false);
|
||||
response.setMessage(message);
|
||||
response.setErrorCode(errorCode);
|
||||
response.setErrorMessage(errorMessage);
|
||||
response.setCreateTime(LocalDateTime.now());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -147,5 +147,6 @@ public class DifyWorkflowResponseDto {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user