sergetshim27 commited on
Commit
29fe3fe
·
verified ·
1 Parent(s): 82fed47

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +5 -3
  2. app.py +18 -6
  3. requirements.txt +4 -5
README.md CHANGED
@@ -5,6 +5,7 @@ colorFrom: indigo
5
  colorTo: blue
6
  sdk: gradio
7
  sdk_version: 5.9.1
 
8
  app_file: app.py
9
  pinned: false
10
  ---
@@ -17,9 +18,10 @@ labeled (Locuteur 1, Locuteur 2, …).
17
 
18
  Send base64 audio, get JSON: `{"segments":[{"speaker","start","end"}...], "num_speakers"}`.
19
 
20
- **Gated models** — you must accept terms for BOTH on the same account as HF_TOKEN:
21
  - pyannote/speaker-diarization-3.1
22
  - pyannote/segmentation-3.0
23
 
24
- Tuned for 2-person interviews/calls (detected, not hard-forced). Heavier than
25
- the STT Space use a paid CPU/GPU tier for usable speed.
 
 
5
  colorTo: blue
6
  sdk: gradio
7
  sdk_version: 5.9.1
8
+ python_version: "3.11"
9
  app_file: app.py
10
  pinned: false
11
  ---
 
18
 
19
  Send base64 audio, get JSON: `{"segments":[{"speaker","start","end"}...], "num_speakers"}`.
20
 
21
+ **Gated models** — accept terms for BOTH on the same account as HF_TOKEN:
22
  - pyannote/speaker-diarization-3.1
23
  - pyannote/segmentation-3.0
24
 
25
+ Pinned to Python 3.11 + torch/torchaudio 2.1.2 (last version with
26
+ `torchaudio.AudioMetaData`, which pyannote 3.3.2 requires). Heavier than the STT
27
+ Space — use a paid CPU/GPU tier for usable speed.
app.py CHANGED
@@ -88,12 +88,24 @@ def diarize_b64(audio_b64):
88
  os.unlink(tmp_path)
89
 
90
  segs = []
91
- for turn, _, speaker in diarization.itertracks(yield_label=True):
92
- segs.append({
93
- "speaker": speaker, # e.g. "SPEAKER_00"
94
- "start": round(float(turn.start), 2),
95
- "end": round(float(turn.end), 2),
96
- })
 
 
 
 
 
 
 
 
 
 
 
 
97
  segs = _merge_segments(segs)
98
 
99
  speakers = sorted({s["speaker"] for s in segs})
 
88
  os.unlink(tmp_path)
89
 
90
  segs = []
91
+ # pyannote 4.x returns an object whose `.speaker_diarization` yields
92
+ # (turn, speaker) pairs. pyannote 3.x returns an Annotation with
93
+ # `.itertracks(yield_label=True)` yielding (turn, _, speaker). Support
94
+ # both so the Space isn't tied to one pyannote version.
95
+ if hasattr(diarization, "speaker_diarization"):
96
+ for turn, speaker in diarization.speaker_diarization:
97
+ segs.append({
98
+ "speaker": str(speaker),
99
+ "start": round(float(turn.start), 2),
100
+ "end": round(float(turn.end), 2),
101
+ })
102
+ else:
103
+ for turn, _, speaker in diarization.itertracks(yield_label=True):
104
+ segs.append({
105
+ "speaker": str(speaker), # e.g. "SPEAKER_00"
106
+ "start": round(float(turn.start), 2),
107
+ "end": round(float(turn.end), 2),
108
+ })
109
  segs = _merge_segments(segs)
110
 
111
  speakers = sorted({s["speaker"] for s in segs})
requirements.txt CHANGED
@@ -1,7 +1,6 @@
1
  gradio==5.9.1
2
- huggingface_hub>=0.26.0
3
- pyannote.audio==3.3.2
4
- torch==2.1.2
5
- torchaudio==2.1.2
6
  soundfile>=0.12.1
7
- numpy<2
 
1
  gradio==5.9.1
2
+ huggingface_hub>=0.30
3
+ pyannote.audio>=4.0.1
4
+ torchaudio>=2.5.0
 
5
  soundfile>=0.12.1
6
+ numpy>=2.0