modelscope-funasr中,非实时语音识别,前端传来了文件给Java后端springboot处理,接着springboot传文件给funasr,funasr把语音识别结果返回给Java后端Java需要传哪些参数?
在使用ModelScope FunASR进行非实时语音识别时,Java后端(Spring Boot)需要从前端接收文件,并将文件传递给FunASR服务以获取语音识别结果。以下是Java后端需要传递的关键参数及其说明:
.apiKey("your-api-key")
model
参数指定,固定为sensevoice-v1
。.model("sensevoice-v1")
.fileUrls(Arrays.asList("https://your-domain.com/file.mp3"))
file
命令、Sox或FFmpeg)检查音频格式并转换为标准格式。Transcription
实例。asyncCall
方法提交任务,传入TranscriptionParam
实例。wait
方法阻塞等待任务完成,或通过fetch
方法轮询任务状态。Transcription transcription = new Transcription();
TranscriptionParam param = TranscriptionParam.builder()
.apiKey("your-api-key")
.model("sensevoice-v1")
.fileUrls(Arrays.asList("https://your-domain.com/file.mp3"))
.build();
TranscriptionResult result = transcription.asyncCall(param);
result.wait(); // 阻塞等待任务完成
language
:指定音频的语言(如中文、英文)。format
:明确音频文件的格式(如WAV、MP3)。sampleRate
:指定音频的采样率(如8000、16000)。通过以上步骤,Java后端可以成功将前端传递的文件发送至FunASR,并获取语音识别结果。