STT流式输入业务逻辑处理
This commit is contained in:
@@ -40,17 +40,17 @@ import java.util.concurrent.CountDownLatch;
|
||||
@Component
|
||||
public class ChatWebSocketHandler {
|
||||
|
||||
@Value("${whisper.apiUrl}")
|
||||
private String API_URL;
|
||||
// @Value("${whisper.apiUrl}")
|
||||
private String API_URL = "wss://api.openai.com/v1/realtime?intent=transcription";
|
||||
|
||||
@Value("${whisper.model}")
|
||||
private String MODEL;
|
||||
// @Value("${whisper.model}")
|
||||
private String MODEL = "gpt-4o-mini-transcribe";
|
||||
|
||||
@Value("${whisper.apiKey}")
|
||||
private String apiKey;
|
||||
// @Value("${whisper.apiKey}")
|
||||
private String apiKey = "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";
|
||||
|
||||
@Value("${whisper.language}")
|
||||
private String language;
|
||||
// @Value("${whisper.language}")
|
||||
private String language = "en";
|
||||
|
||||
/**
|
||||
* 16kHz
|
||||
@@ -183,9 +183,9 @@ public class ChatWebSocketHandler {
|
||||
byteBuffer.get(bytes);
|
||||
log.info("2、开始接收数据流时间:{}",System.currentTimeMillis()/1000);
|
||||
// 生成唯一文件名
|
||||
String fileName = clientId + "_" + System.currentTimeMillis() + ".webm";
|
||||
String pathUrl = RuoYiConfig.getProfile()+VOICE_STORAGE_DIR + fileName;
|
||||
log.info("文件路径为:{}", pathUrl);
|
||||
// String fileName = clientId + "_" + System.currentTimeMillis() + ".webm";
|
||||
// String pathUrl = RuoYiConfig.getProfile()+VOICE_STORAGE_DIR + fileName;
|
||||
// log.info("文件路径为:{}", pathUrl);
|
||||
log.info("3、开始接收数据流时间:{}",System.currentTimeMillis()/1000);
|
||||
try{
|
||||
//接收到数据流后直接就进行SST处理
|
||||
@@ -306,7 +306,7 @@ public class ChatWebSocketHandler {
|
||||
JSONObject transcription = new JSONObject();
|
||||
JSONObject turnDetection = new JSONObject();
|
||||
// 配置转录参数
|
||||
transcription.put("model", "gpt-4o-mini-transcribe");
|
||||
transcription.put("model", MODEL);
|
||||
transcription.put("language", language); // 中文
|
||||
// 配置断句检测
|
||||
turnDetection.put("type", "server_vad");
|
||||
|
||||
Reference in New Issue
Block a user