MCPcopy Create free account
hub / github.com/modelscope/FunASR / asr_endpoint

Function asr_endpoint

funasr/bin/_server_app.py:247–275  ·  view source on GitHub ↗

Full-featured ASR endpoint with timestamps and speaker diarization.

(
        file: UploadFile = File(...),
        language: Optional[str] = Form(default=None),
        hotwords: str = Form(default=""),
        spk: bool = Form(default=False),
    )

Source from the content-addressed store, hash-verified

245
246 @app.post("/asr")
247 async def asr_endpoint(
248 file: UploadFile = File(...),
249 language: Optional[str] = Form(default=None),
250 hotwords: str = Form(default=""),
251 spk: bool = Form(default=False),
252 ):
253 """Full-featured ASR endpoint with timestamps and speaker diarization."""
254 content = await file.read()
255 _load_vllm_engine()
256 hw_list = [w.strip() for w in hotwords.split(",") if w.strip()] if hotwords else None
257
258 t0 = time.perf_counter()
259 if app.state.use_vllm:
260 audio_data, sr = sf.read(io.BytesIO(content))
261 result = _process_vllm(audio_data, sr, language=language, hotwords=hw_list, use_spk=spk)
262 else:
263 suffix = ".wav"
264 with tempfile.NamedTemporaryFile(delete=False, suffix=suffix) as tmp:
265 tmp.write(content)
266 tmp_path = tmp.name
267 try:
268 result = _process_fallback("fun-asr-nano", tmp_path, language=language)
269 finally:
270 os.unlink(tmp_path)
271 t1 = time.perf_counter()
272
273 result["processing_time"] = round(t1 - t0, 3)
274 result["rtf"] = round((t1 - t0) / result["duration"], 4) if result.get("duration", 0) > 0 else 0
275 return JSONResponse(result)
276
277 @app.get("/v1/models")
278 async def list_models():

Callers

nothing calls this directly

Calls 6

_load_vllm_engineFunction · 0.85
_process_vllmFunction · 0.85
_process_fallbackFunction · 0.85
FileClass · 0.50
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…