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

Return diarization segments as JSON

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -213,13 +213,15 @@ def diarize(
213
  f"- ZeroGPU time used: **{zerogpu_seconds:.2f}s**"
214
  )
215
 
216
- table = [
217
- [
218
- segment["speaker"],
219
- _format_timestamp(segment["start"]),
220
- _format_timestamp(segment["end"]),
221
- round(segment["duration"], 3),
222
- ]
 
 
223
  for segment in segments
224
  ]
225
 
@@ -229,7 +231,7 @@ def diarize(
229
  )
230
 
231
  artifacts = _write_artifacts(segments, rttm_text)
232
- return summary, round(zerogpu_seconds, 3), table, turns_text, artifacts
233
 
234
 
235
  def build_demo() -> gr.Blocks:
@@ -269,12 +271,7 @@ def build_demo() -> gr.Blocks:
269
  with gr.Column(scale=1):
270
  summary_output = gr.Markdown()
271
  zerogpu_seconds_output = gr.Number(label="ZeroGPU seconds used", precision=3)
272
- segments_output = gr.Dataframe(
273
- headers=["Speaker", "Start", "End", "Duration (s)"],
274
- datatype=["str", "str", "str", "number"],
275
- interactive=False,
276
- label="Segments",
277
- )
278
  turns_output = gr.Textbox(
279
  label="Speaker turns",
280
  lines=14,
@@ -294,7 +291,7 @@ def build_demo() -> gr.Blocks:
294
 
295
  gr.Markdown(
296
  """
297
- Outputs include a segment table, a plain-text speaker-turn list, and downloadable
298
  `CSV`, `TXT`, and `RTTM` files.
299
  """
300
  )
 
213
  f"- ZeroGPU time used: **{zerogpu_seconds:.2f}s**"
214
  )
215
 
216
+ segments_json = [
217
+ {
218
+ **segment,
219
+ "start": round(segment["start"], 3),
220
+ "end": round(segment["end"], 3),
221
+ "duration": round(segment["duration"], 3),
222
+ "start_timestamp": _format_timestamp(segment["start"]),
223
+ "end_timestamp": _format_timestamp(segment["end"]),
224
+ }
225
  for segment in segments
226
  ]
227
 
 
231
  )
232
 
233
  artifacts = _write_artifacts(segments, rttm_text)
234
+ return summary, round(zerogpu_seconds, 3), segments_json, turns_text, artifacts
235
 
236
 
237
  def build_demo() -> gr.Blocks:
 
271
  with gr.Column(scale=1):
272
  summary_output = gr.Markdown()
273
  zerogpu_seconds_output = gr.Number(label="ZeroGPU seconds used", precision=3)
274
+ segments_output = gr.JSON(label="Segments JSON")
 
 
 
 
 
275
  turns_output = gr.Textbox(
276
  label="Speaker turns",
277
  lines=14,
 
291
 
292
  gr.Markdown(
293
  """
294
+ Outputs include segments as JSON, a plain-text speaker-turn list, and downloadable
295
  `CSV`, `TXT`, and `RTTM` files.
296
  """
297
  )