Commit Graph

4 Commits

Author SHA1 Message Date
IT狗 9a93cb6ffd transcribe_server: bypass whisperx DiarizationPipeline, use raw pyannote Pipeline
Speaker labels were empty because whisperx 3.8.5's DiarizationPipeline wrapper
has a compatibility bug with pyannote.audio 4.0.4: the wrapper silently returns
empty segments (the 'fallback to plain text' message in 3.8.5 logs), so
segments.speaker becomes '' instead of 'SPEAKER_XX'.

Fix: load pyannote.audio.Pipeline directly and convert DiarizeOutput →
DataFrame the same way whisperx/diarize.py does internally. Verified with 30s
Cantonese clip from real recording (chunk_0.mp3):

  speaker: SPEAKER_00  (was '')
  text: '那就係F5嘅Low Balancer用喺你哋嘅...特別感謝Sherry...'
  took: 34s for 30s audio (1.13x realtime, CPU int8 + diarize=1)
  curl http://localhost:8765/transcribe -F file=@test.wav -F language=yue -F diarize=1
2026-08-12 01:34:45 +08:00
IT狗 335b0d8ee5 FIX: pre-encode mp3→wav + preloaded audio dict for pyannote (FFmpeg 8 / torchcodec 0.7 broken)
ROOT CAUSE
- whisperx venv has torchcodec 0.7.0 + PyTorch 2.8.0 → torchcodec dylibs target
  FFmpeg 4-7 (libavutil.56-.59) but Mac brew now ships FFmpeg 8 (libavutil.60).
- All audio loading via torchcodec silently fails (warning but hangs/returns 0).

FIX
- /transcribe endpoint: pre-encode uploaded mp3/webm → 16kHz mono WAV via
  subprocess ffmpeg (whisperx.load_audio then reads clean PCM file).
- _do_transcribe diarize branch: pass {'waveform': tensor, 'sample_rate': int}
  dict to pyannote Pipeline instead of file path → skips torchcodec entirely.

Tested
- chunk_0.mp3 (4MB, 5min): diarize=0 → 200 OK + hallucination filter triggered
- Confirmed working in live HTTP POST at 15:40 HKT
2026-08-11 15:47:00 +08:00
IT狗 3126021d2e FIX: preset language=zh in whisperx load_model to prevent tokenizer race on long audio (32+ min)
- Bug: long audio (32+ min) batched inference hit NoneType 'sot_sequence' error
- Root cause: faster-whisper tokenizer reset to None between VAD chunks for multilingual inference when preset_language is None
- Fix: load model with language='zh' to set preset_language, avoiding tokenizer reset
- Side effect: slightly faster (no language detection per file)

Tested on F5 Tech Refresh meeting (32:46 audio, 80 segments, 8072 chars)
Previous: failed with AttributeError: 'NoneType' object has no attribute 'sot_sequence'
After: full transcript + summary generated successfully
2026-08-10 23:26:26 +08:00
IT狗 f316b9bbbc v1.3.0: large-v3 + hallucination filter (2026-07-24)
IT狗今日升級嘅 transcribe server:
- Model: large-v3-turbo → large-v3 (+2-3% Cantonese WER improvement)
- Compute: cpu + int8 (MPS fp16 unstable for large-v3 on 16GB Mac)
- Beam: 5 → 1 (greedy, ~30-40% speedup)
- Added: condition_on_previous_text=False (anti-hallucination chain)
- Added: compression_ratio_threshold=2.4 (repetitive noise filter)
- Added: no_speech_threshold=0.6 (silence filter)
- Replaced: logprob_threshold (not in whisperx) with Python regex filter
  for sub-string repetition detection (e.g. '对,有自己的监控,IP' × 20)
- Test: 6.1MB / 6:38 voice memo → 358s = 1.15x realtime
- Test: 3 speakers correctly identified (SPEAKER_00/01/02)
- Test: code-mixing OK (Cantonese + English terms preserved)

Backup: transcribe_server.py.bak-20260724-0931
v1.3.0
2026-07-24 23:53:01 +08:00