LiamKhoaLe commited on
Commit
c0167f3
·
1 Parent(s): 6071f20

Upd turbo model configs #2

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -34,10 +34,15 @@ pipe = pipeline(
34
  def transcribe(inputs, task, summarize=False):
35
  if inputs is None:
36
  raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
37
-
38
- text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
 
 
39
  if summarize:
40
- summary = summarize_with_gemini(text)
 
 
 
41
  return text, summary
42
  return text, ""
43
 
@@ -94,8 +99,16 @@ def yt_transcribe(yt_url, task, summarize=False, max_filesize=75.0):
94
  inputs = ffmpeg_read(inputs, pipe.feature_extractor.sampling_rate)
95
  inputs = {"array": inputs, "sampling_rate": pipe.feature_extractor.sampling_rate}
96
 
97
- text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
98
- summary = summarize_with_gemini(text) if summarize else ""
 
 
 
 
 
 
 
 
99
  return html_embed_str, text, summary
100
 
101
 
 
34
  def transcribe(inputs, task, summarize=False):
35
  if inputs is None:
36
  raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
37
+ try:
38
+ text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
39
+ except Exception as e:
40
+ raise gr.Error(f"Transcription failed: {e}")
41
  if summarize:
42
+ try:
43
+ summary = summarize_with_gemini(text)
44
+ except Exception as e:
45
+ summary = f"Summary error: {e}"
46
  return text, summary
47
  return text, ""
48
 
 
99
  inputs = ffmpeg_read(inputs, pipe.feature_extractor.sampling_rate)
100
  inputs = {"array": inputs, "sampling_rate": pipe.feature_extractor.sampling_rate}
101
 
102
+ try:
103
+ text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"]
104
+ except Exception as e:
105
+ raise gr.Error(f"Transcription failed: {e}")
106
+ summary = ""
107
+ if summarize:
108
+ try:
109
+ summary = summarize_with_gemini(text)
110
+ except Exception as e:
111
+ summary = f"Summary error: {e}"
112
  return html_embed_str, text, summary
113
 
114