From 21866ec334a0abfaee490fe7405baea87314f236 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Jun 2026 17:42:33 +0000 Subject: [PATCH] =?UTF-8?q?Filtrage=20des=20interjections=20chinoises=20de?= =?UTF-8?q?=20Qwen3-ASR=20(=E5=97=AF,=20=E5=92=B3=E5=92=B3...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://claude.ai/code/session_01YHMp3EKzr4s6o8w1ygxuUe --- app/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/main.py b/app/main.py index 74c5915..8391d5a 100644 --- a/app/main.py +++ b/app/main.py @@ -5,6 +5,7 @@ import hmac import io import json import os +import re import secrets import time import wave @@ -26,6 +27,21 @@ ASR_MODEL = os.environ.get("ASR_MODEL", "Qwen/Qwen3-ASR-1.7B") ASR_API_KEY = os.environ.get("ASR_API_KEY", "sk-local") ASR_LANGUAGE = os.environ.get("ASR_LANGUAGE", "").strip() +# Qwen3-ASR transcrit les sons non verbaux (hmm, toux...) en interjections +# chinoises et vLLM ignore le paramètre language : si la langue configurée +# n'est pas une langue CJK, on retire ces caractères des transcriptions. +CJK_RE = re.compile(r"[ -〿㐀-䶿一-鿿豈-﫿＀-￯]+") +STRIP_CJK = ASR_LANGUAGE.lower() not in ("", "zh", "ja", "ko", "yue") + + +def clean_transcript(text: str) -> str: + if STRIP_CJK and CJK_RE.search(text): + text = CJK_RE.sub(" ", text) + text = re.sub(r"\s+", " ", text) + text = text.lstrip(" 。,、!?.,;!?") # ponctuation orpheline en tête + text = text.rstrip(" 。,、!?") # ponctuation chinoise en queue + return text.strip() + LIVEFLOW_USER = os.environ.get("LIVEFLOW_USER", "admin") LIVEFLOW_PASSWORD = os.environ.get("LIVEFLOW_PASSWORD", "admin") SESSION_TTL = 7 * 24 * 3600 # 7 jours @@ -241,6 +257,10 @@ async def ws_transcribe(ws: WebSocket): print(f"[réunion {meeting_id}] ERREUR ASR : {exc}", flush=True) await ws.send_json({"type": "error", "message": f"Transcription échouée : {exc}"}) continue + cleaned = clean_transcript(text) + if cleaned != text: + print(f"[réunion {meeting_id}] filtré (CJK) : {text[:60]!r} -> {cleaned[:60]!r}", flush=True) + text = cleaned print(f"[réunion {meeting_id}] texte : {text[:80]!r}", flush=True) if not text: continue