tried to fix transcibe failures
This commit is contained in:
@@ -5,6 +5,7 @@ SMTP_PASSWORD=your_smtp_password_here
|
||||
SMTP_FROM=Meeting Transcription Service
|
||||
AZURE_SPEECH_ENDPOINT=https://your-speech-resource.cognitiveservices.azure.com/
|
||||
AZURE_SPEECH_KEY=your_azure_speech_key_here
|
||||
AZURE_SPEECH_LOCALE=de-DE
|
||||
AZURE_SPEECH_DIARIZATION_ENABLED=true
|
||||
AZURE_SPEECH_MAX_SPEAKERS=8
|
||||
AZURE_SPEECH_LLM_PROMPT=Transkribiere dieses Geschäftsmeeting mit hoher Genauigkeit auf Deutsch. Bewahre Formulierung und Bedeutung so genau wie möglich. Fasse nichts zusammen, schreibe nichts um und ergänze keine Erklärungen. Setze saubere Interpunktion und klare Satzgrenzen. Trenne Sprecherwechsel gemäß der Audioaufnahme. Bewahre Fachbegriffe, Eigennamen, Akronyme, Zahlen, Währungen, Datumsangaben, Aufgaben und fremdsprachige Begriffe exakt. Gib nur das Transkript aus.
|
||||
|
||||
41
main.py
41
main.py
@@ -108,15 +108,8 @@ def is_azure_direct_upload_supported(file_path: Path, fmt: str) -> bool:
|
||||
".mp3",
|
||||
".ogg",
|
||||
".flac",
|
||||
".webm",
|
||||
".wma",
|
||||
".aac",
|
||||
".amr",
|
||||
".speex",
|
||||
".m4a",
|
||||
".mp4",
|
||||
}
|
||||
supported_formats = {"wav", "mp3", "ogg", "flac", "webm"}
|
||||
supported_formats = {"wav", "mp3", "ogg", "flac"}
|
||||
return file_path.suffix.lower() in supported_exts or fmt in supported_formats
|
||||
|
||||
|
||||
@@ -150,6 +143,15 @@ def _build_azure_definition() -> dict:
|
||||
},
|
||||
"profanityFilterMode": os.getenv("AZURE_SPEECH_PROFANITY_MODE", "Masked"),
|
||||
}
|
||||
locales_raw = (
|
||||
os.getenv("AZURE_SPEECH_LOCALES", "").strip()
|
||||
or os.getenv("AZURE_SPEECH_LOCALE", "").strip()
|
||||
)
|
||||
if locales_raw:
|
||||
locales = [item.strip() for item in locales_raw.split(",") if item.strip()]
|
||||
if locales:
|
||||
definition["locales"] = locales
|
||||
|
||||
prompt = os.getenv("AZURE_SPEECH_LLM_PROMPT", "").strip()
|
||||
if prompt:
|
||||
definition["enhancedMode"]["prompt"] = [prompt]
|
||||
@@ -175,7 +177,17 @@ def _encode_multipart_form(fields: dict[str, str], file_field: str, file_path: P
|
||||
body.extend(value.encode("utf-8"))
|
||||
body.extend(b"\r\n")
|
||||
|
||||
mime_type = "audio/wav" if file_path.suffix.lower() == ".wav" else "application/octet-stream"
|
||||
mime_types = {
|
||||
".wav": "audio/wav",
|
||||
".mp3": "audio/mpeg",
|
||||
".ogg": "audio/ogg",
|
||||
".flac": "audio/flac",
|
||||
".webm": "audio/webm",
|
||||
".aac": "audio/aac",
|
||||
".m4a": "audio/mp4",
|
||||
".mp4": "audio/mp4",
|
||||
}
|
||||
mime_type = mime_types.get(file_path.suffix.lower(), "application/octet-stream")
|
||||
body.extend(f"--{boundary}\r\n".encode("utf-8"))
|
||||
body.extend(
|
||||
(
|
||||
@@ -244,7 +256,16 @@ def _format_azure_transcript(result: dict) -> str:
|
||||
if merged_text:
|
||||
return f"SPRECHER: {merged_text}"
|
||||
|
||||
raise RuntimeError("Azure Speech lieferte kein Transkript zurück")
|
||||
diagnostics = {
|
||||
"durationMilliseconds": result.get("durationMilliseconds"),
|
||||
"keys": sorted(result.keys()),
|
||||
}
|
||||
preview = json.dumps(result, ensure_ascii=False)[:1200]
|
||||
raise RuntimeError(
|
||||
"Azure Speech lieferte kein Transkript zurück. "
|
||||
f"Diagnose={json.dumps(diagnostics, ensure_ascii=False)} "
|
||||
f"Antwort={preview}"
|
||||
)
|
||||
|
||||
|
||||
def transcribe_audio(file_path: Path) -> str:
|
||||
|
||||
Reference in New Issue
Block a user