Zeph27 commited on
Commit
b72617b
1 Parent(s): 40a56d1

update processing time

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -67,6 +67,7 @@ def summarize_transcription(transcription, model, gemini_prompt):
67
  @spaces.GPU(duration=120)
68
  def process_audio(audio_file, language, whisper_model):
69
  print("Starting transcription...")
 
70
 
71
  if device == 0:
72
  pipe = load_pipeline(whisper_model)
@@ -85,10 +86,12 @@ def process_audio(audio_file, language, whisper_model):
85
  else:
86
  print("No language defined, using default language")
87
  transcription = pipe(inputs, batch_size=8, generate_kwargs={"task": "transcribe"}, return_timestamps=True)["text"]
88
- return transcription
 
 
 
89
 
90
  def transcribe(youtube_url, audio_file, whisper_model, gemini_api_key, gemini_prompt, gemini_model_variant, language, progress=gr.Progress()):
91
- start_time = time.time()
92
  try:
93
  progress(0, desc="Initializing")
94
  if not gemini_api_key:
@@ -112,7 +115,7 @@ def transcribe(youtube_url, audio_file, whisper_model, gemini_api_key, gemini_pr
112
  print(f"Audio file read: {audio_file}")
113
 
114
  progress(0.4, desc="Starting transcription")
115
- transcription = process_audio(audio_file, language, whisper_model)
116
 
117
  progress(0.6, desc="Cleaning up")
118
  # Delete the audio file after transcription
@@ -142,9 +145,7 @@ def transcribe(youtube_url, audio_file, whisper_model, gemini_api_key, gemini_pr
142
 
143
  progress(1, desc="Complete")
144
  print("Transcription and summarization complete.")
145
- end_time = time.time()
146
- total_time = round(end_time - start_time, 2)
147
- return transcription_message, summary_message, transcription_file, summary_file, total_time
148
  except gr.Error as e:
149
  # Re-raise Gradio errors
150
  raise e
@@ -187,7 +188,7 @@ with gr.Blocks(theme='NoCrypt/miku') as demo:
187
  summary_output = gr.Textbox(label="Summary Output")
188
  transcription_file = gr.File(label="Download Transcription")
189
  summary_file = gr.File(label="Download Summary")
190
- processing_time = gr.Textbox(label="Total Processing Time (seconds)")
191
 
192
  input_type.change(fn=toggle_input, inputs=input_type, outputs=[youtube_url, audio_file])
193
  define_language.change(fn=toggle_language, inputs=define_language, outputs=[language])
 
67
  @spaces.GPU(duration=120)
68
  def process_audio(audio_file, language, whisper_model):
69
  print("Starting transcription...")
70
+ start_time = time.time()
71
 
72
  if device == 0:
73
  pipe = load_pipeline(whisper_model)
 
86
  else:
87
  print("No language defined, using default language")
88
  transcription = pipe(inputs, batch_size=8, generate_kwargs={"task": "transcribe"}, return_timestamps=True)["text"]
89
+
90
+ end_time = time.time()
91
+ processing_time = round(end_time - start_time, 2)
92
+ return transcription, processing_time
93
 
94
  def transcribe(youtube_url, audio_file, whisper_model, gemini_api_key, gemini_prompt, gemini_model_variant, language, progress=gr.Progress()):
 
95
  try:
96
  progress(0, desc="Initializing")
97
  if not gemini_api_key:
 
115
  print(f"Audio file read: {audio_file}")
116
 
117
  progress(0.4, desc="Starting transcription")
118
+ transcription, processing_time = process_audio(audio_file, language, whisper_model)
119
 
120
  progress(0.6, desc="Cleaning up")
121
  # Delete the audio file after transcription
 
145
 
146
  progress(1, desc="Complete")
147
  print("Transcription and summarization complete.")
148
+ return transcription_message, summary_message, transcription_file, summary_file, processing_time
 
 
149
  except gr.Error as e:
150
  # Re-raise Gradio errors
151
  raise e
 
188
  summary_output = gr.Textbox(label="Summary Output")
189
  transcription_file = gr.File(label="Download Transcription")
190
  summary_file = gr.File(label="Download Summary")
191
+ processing_time = gr.Textbox(label="Transcription Processing Time (seconds)")
192
 
193
  input_type.change(fn=toggle_input, inputs=input_type, outputs=[youtube_url, audio_file])
194
  define_language.change(fn=toggle_language, inputs=define_language, outputs=[language])