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