From 80176e9f8297c8438b56c59b1d7d5d3bb19cf60d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Jun 2026 09:33:40 +0000 Subject: [PATCH] =?UTF-8?q?ASR=20:=20repli=20automatique=20sans=20le=20par?= =?UTF-8?q?am=C3=A8tre=20language=20refus=C3=A9=20par=20certains=20moteurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vLLM avec Qwen3-ASR peut répondre 400 quand 'language' est fourni. L'app retente alors en détection automatique, et les erreurs ASR remontent désormais avec le corps de la réponse pour faciliter le diagnostic. Ajout du favicon (404 dans la console). https://claude.ai/code/session_01YHMp3EKzr4s6o8w1ygxuUe --- app/main.py | 27 ++++++++++++++++++++------- app/static/index.html | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/main.py b/app/main.py index 9ff84d5..4130f3c 100644 --- a/app/main.py +++ b/app/main.py @@ -67,17 +67,30 @@ def pcm_to_wav(pcm: bytes) -> bytes: return buf.getvalue() -async def transcribe(pcm: bytes) -> str: - data = {"model": ASR_MODEL} - if ASR_LANGUAGE: - data["language"] = ASR_LANGUAGE - resp = await http.post( +async def _post_transcription(data: dict, wav: bytes) -> httpx.Response: + return await http.post( f"{ASR_BASE_URL}/audio/transcriptions", headers={"Authorization": f"Bearer {ASR_API_KEY}"}, data=data, - files={"file": ("segment.wav", pcm_to_wav(pcm), "audio/wav")}, + files={"file": ("segment.wav", wav, "audio/wav")}, ) - resp.raise_for_status() + + +async def transcribe(pcm: bytes) -> str: + wav = pcm_to_wav(pcm) + data = {"model": ASR_MODEL} + if ASR_LANGUAGE: + data["language"] = ASR_LANGUAGE + resp = await _post_transcription(data, wav) + if resp.status_code == 400 and "language" in data: + # Certains moteurs (ex. Qwen3-ASR via vLLM) rejettent le paramètre + # language : on retente en laissant la détection automatique. + print(f"ASR a refusé language={ASR_LANGUAGE!r} ({resp.text[:200]}), " + "nouvel essai sans ce paramètre", flush=True) + del data["language"] + resp = await _post_transcription(data, wav) + if resp.status_code != 200: + raise RuntimeError(f"ASR HTTP {resp.status_code} : {resp.text[:300]}") return resp.json().get("text", "").strip() diff --git a/app/static/index.html b/app/static/index.html index 0339993..99c72f4 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -4,6 +4,7 @@ LiveFlow — Transcription de réunions +