muhtasham commited on
Commit
a231b66
·
1 Parent(s): 0900fc2
Files changed (1) hide show
  1. app.py +8 -18
app.py CHANGED
@@ -270,11 +270,6 @@ def transcribe_youtube(url, return_timestamps, generate_subs, chunk_length_s=15,
270
  logger.info(f"Transcription metadata: {metadata}")
271
  logger.info(f"Transcription completed in {metadata.get('timing', {}).get('total_time', 0):.2f} seconds")
272
 
273
- # Format response with segments (without id)
274
- logger.info("Formatting response...")
275
- formatted_result = result["transcription"]
276
- logger.info(f"Formatted result contains {len(formatted_result['segments'])} segments")
277
-
278
  # Generate subtitles if requested
279
  srt_file = None
280
  if generate_subs and return_timestamps and "segments" in result["transcription"]:
@@ -284,7 +279,7 @@ def transcribe_youtube(url, return_timestamps, generate_subs, chunk_length_s=15,
284
  logger.info(f"Generated SRT file: {srt_file}")
285
 
286
  logger.info("YouTube transcription process completed successfully")
287
- return {"transcription": formatted_result, "metadata": result["metadata"]}, result, srt_file, ""
288
 
289
  except Exception as e:
290
  logger.exception(f"Error in YouTube transcription: {str(e)}")
@@ -331,11 +326,6 @@ def transcribe(inputs, return_timestamps, generate_subs, chunk_length_s=15, batc
331
  logger.info(f"Transcription metadata: {metadata}")
332
  logger.info(f"Transcription completed in {metadata.get('timing', {}).get('total_time', 0):.2f} seconds")
333
 
334
- # Format response with segments (without id)
335
- logger.info("Formatting response...")
336
- formatted_result = result["transcription"]
337
- logger.info(f"Formatted result contains {len(formatted_result['segments'])} segments")
338
-
339
  # Generate subtitles if requested
340
  srt_file = None
341
  if generate_subs and return_timestamps and "segments" in result["transcription"]:
@@ -345,7 +335,7 @@ def transcribe(inputs, return_timestamps, generate_subs, chunk_length_s=15, batc
345
  logger.info(f"Generated SRT file: {srt_file}")
346
 
347
  logger.info("Transcription process completed successfully")
348
- return {"transcription": formatted_result, "metadata": result["metadata"]}, result, srt_file, ""
349
 
350
  except requests.exceptions.RequestException as e:
351
  logger.exception(f"API request failed: {str(e)}")
@@ -368,9 +358,9 @@ youtube_transcribe = gr.Interface(
368
  gr.Slider(minimum=8, maximum=128, value=8, step=8, label="Batch Size")
369
  ],
370
  outputs=[
371
- gr.JSON(label="Formatted Response", open=True),
372
- gr.JSON(label="Raw API Response", open=True),
373
  gr.File(label="Subtitles (SRT)", visible=True),
 
374
  ],
375
  title="Tajik Speech Transcription",
376
  description=(
@@ -393,9 +383,9 @@ mf_transcribe = gr.Interface(
393
  gr.Slider(minimum=8, maximum=128, value=8, step=8, label="Batch Size")
394
  ],
395
  outputs=[
396
- gr.JSON(label="Formatted Response", open=True),
397
- gr.JSON(label="Raw API Response", open=True),
398
  gr.File(label="Subtitles (SRT)", visible=True),
 
399
  ],
400
  title="Tajik Speech Transcription",
401
  description=(
@@ -415,9 +405,9 @@ file_transcribe = gr.Interface(
415
  gr.Slider(minimum=8, maximum=128, value=8, step=8, label="Batch Size")
416
  ],
417
  outputs=[
418
- gr.JSON(label="Formatted Response", open=True),
419
- gr.JSON(label="Raw API Response", open=True),
420
  gr.File(label="Subtitles (SRT)", visible=True),
 
421
  ],
422
  title="Tajik Speech Transcription",
423
  description=(
 
270
  logger.info(f"Transcription metadata: {metadata}")
271
  logger.info(f"Transcription completed in {metadata.get('timing', {}).get('total_time', 0):.2f} seconds")
272
 
 
 
 
 
 
273
  # Generate subtitles if requested
274
  srt_file = None
275
  if generate_subs and return_timestamps and "segments" in result["transcription"]:
 
279
  logger.info(f"Generated SRT file: {srt_file}")
280
 
281
  logger.info("YouTube transcription process completed successfully")
282
+ return result, srt_file, ""
283
 
284
  except Exception as e:
285
  logger.exception(f"Error in YouTube transcription: {str(e)}")
 
326
  logger.info(f"Transcription metadata: {metadata}")
327
  logger.info(f"Transcription completed in {metadata.get('timing', {}).get('total_time', 0):.2f} seconds")
328
 
 
 
 
 
 
329
  # Generate subtitles if requested
330
  srt_file = None
331
  if generate_subs and return_timestamps and "segments" in result["transcription"]:
 
335
  logger.info(f"Generated SRT file: {srt_file}")
336
 
337
  logger.info("Transcription process completed successfully")
338
+ return result, srt_file, ""
339
 
340
  except requests.exceptions.RequestException as e:
341
  logger.exception(f"API request failed: {str(e)}")
 
358
  gr.Slider(minimum=8, maximum=128, value=8, step=8, label="Batch Size")
359
  ],
360
  outputs=[
361
+ gr.JSON(label="API Response", open=True),
 
362
  gr.File(label="Subtitles (SRT)", visible=True),
363
+ gr.Textbox(label="Error", visible=False)
364
  ],
365
  title="Tajik Speech Transcription",
366
  description=(
 
383
  gr.Slider(minimum=8, maximum=128, value=8, step=8, label="Batch Size")
384
  ],
385
  outputs=[
386
+ gr.JSON(label="API Response", open=True),
 
387
  gr.File(label="Subtitles (SRT)", visible=True),
388
+ gr.Textbox(label="Error", visible=False)
389
  ],
390
  title="Tajik Speech Transcription",
391
  description=(
 
405
  gr.Slider(minimum=8, maximum=128, value=8, step=8, label="Batch Size")
406
  ],
407
  outputs=[
408
+ gr.JSON(label="API Response", open=True),
 
409
  gr.File(label="Subtitles (SRT)", visible=True),
410
+ gr.Textbox(label="Error", visible=False)
411
  ],
412
  title="Tajik Speech Transcription",
413
  description=(