Ratnesh-dev commited on
Commit
1103803
·
1 Parent(s): 71acebe

Simplify API-only diarization inputs

Browse files
Files changed (1) hide show
  1. app.py +2 -12
app.py CHANGED
@@ -102,7 +102,6 @@ def _normalize_audio(audio_path: str) -> str:
102
  def _run_diarization(
103
  audio_path: str,
104
  hf_token: str,
105
- prefer_exclusive: bool,
106
  ) -> tuple[list[dict[str, Any]], str, str, float]:
107
  pipeline = get_pipeline(hf_token)
108
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
@@ -124,7 +123,7 @@ def _run_diarization(
124
  annotation_label = "speaker_diarization"
125
 
126
  exclusive_annotation = getattr(output, "exclusive_speaker_diarization", None)
127
- if prefer_exclusive and exclusive_annotation is not None:
128
  annotation = exclusive_annotation
129
  annotation_label = "exclusive_speaker_diarization"
130
 
@@ -173,7 +172,6 @@ def _write_artifacts(segments: list[dict[str, Any]], rttm_text: str) -> list[str
173
  def diarize(
174
  audio_path: str | None,
175
  hf_token: str | None,
176
- prefer_exclusive: bool,
177
  ):
178
  if not audio_path:
179
  raise gr.Error("Upload or record an audio file first.")
@@ -190,7 +188,6 @@ def diarize(
190
  segments, rttm_text, annotation_label, zerogpu_seconds = _run_diarization(
191
  audio_path=normalized_audio_path,
192
  hf_token=resolved_token,
193
- prefer_exclusive=prefer_exclusive,
194
  )
195
 
196
  if not segments:
@@ -251,7 +248,7 @@ def build_demo() -> gr.Blocks:
251
  with gr.Row():
252
  with gr.Column(scale=1):
253
  audio_input = gr.Audio(
254
- sources=["upload", "microphone"],
255
  type="filepath",
256
  label="Audio",
257
  )
@@ -260,12 +257,6 @@ def build_demo() -> gr.Blocks:
260
  type="password",
261
  placeholder="hf_xxx",
262
  )
263
- prefer_exclusive = gr.Checkbox(
264
- value=True,
265
- label="Prefer exclusive speaker diarization when available",
266
- )
267
-
268
-
269
  run_button = gr.Button("Run diarization", variant="primary")
270
 
271
  with gr.Column(scale=1):
@@ -284,7 +275,6 @@ def build_demo() -> gr.Blocks:
284
  inputs=[
285
  audio_input,
286
  token_input,
287
- prefer_exclusive,
288
  ],
289
  outputs=[summary_output, zerogpu_seconds_output, segments_output, turns_output, files_output],
290
  )
 
102
  def _run_diarization(
103
  audio_path: str,
104
  hf_token: str,
 
105
  ) -> tuple[list[dict[str, Any]], str, str, float]:
106
  pipeline = get_pipeline(hf_token)
107
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
123
  annotation_label = "speaker_diarization"
124
 
125
  exclusive_annotation = getattr(output, "exclusive_speaker_diarization", None)
126
+ if exclusive_annotation is not None:
127
  annotation = exclusive_annotation
128
  annotation_label = "exclusive_speaker_diarization"
129
 
 
172
  def diarize(
173
  audio_path: str | None,
174
  hf_token: str | None,
 
175
  ):
176
  if not audio_path:
177
  raise gr.Error("Upload or record an audio file first.")
 
188
  segments, rttm_text, annotation_label, zerogpu_seconds = _run_diarization(
189
  audio_path=normalized_audio_path,
190
  hf_token=resolved_token,
 
191
  )
192
 
193
  if not segments:
 
248
  with gr.Row():
249
  with gr.Column(scale=1):
250
  audio_input = gr.Audio(
251
+ sources=["upload"],
252
  type="filepath",
253
  label="Audio",
254
  )
 
257
  type="password",
258
  placeholder="hf_xxx",
259
  )
 
 
 
 
 
 
260
  run_button = gr.Button("Run diarization", variant="primary")
261
 
262
  with gr.Column(scale=1):
 
275
  inputs=[
276
  audio_input,
277
  token_input,
 
278
  ],
279
  outputs=[summary_output, zerogpu_seconds_output, segments_output, turns_output, files_output],
280
  )