Ofiroz91 commited on
Commit
ec2db99
โ€ข
1 Parent(s): ffdd052

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -11,7 +11,7 @@ model = WhisperModel("ivrit-ai/faster-whisper-v2-d4")
11
  # ื”ื’ื“ืจืช pipeline ืœืกื™ื›ื•ื
12
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
13
 
14
- def summarize_audio_or_video(file_path):
15
  try:
16
  # ื‘ื“ื™ืงื” ืื ื”ืงื•ื‘ืฅ ื”ื•ื ื•ื™ื“ืื• ื•ื”ืžืจืช ื•ื™ื“ืื• ืœืื•ื“ื™ื• ื‘ืžื™ื“ืช ื”ืฆื•ืจืš
17
  if file_path.endswith((".mp4", ".mov", ".avi", ".mkv")):
@@ -30,10 +30,10 @@ def summarize_audio_or_video(file_path):
30
  if audio_file != file_path:
31
  os.remove(audio_file)
32
 
33
- return summary
34
 
35
  except Exception as e:
36
- return f"ืฉื’ื™ืื” ื‘ืขื™ื‘ื•ื“ ื”ืงื•ื‘ืฅ: {str(e)}"
37
 
38
  def convert_video_to_audio(video_file):
39
  # ื™ืฆื™ืจืช ืงื•ื‘ืฅ ืื•ื“ื™ื• ื–ืžื ื™
@@ -44,11 +44,11 @@ def convert_video_to_audio(video_file):
44
 
45
  # ื”ื’ื“ืจืช ืžืžืฉืง Gradio
46
  interface = gr.Interface(
47
- fn=summarize_audio_or_video,
48
  inputs=gr.Audio(type="filepath"),
49
- outputs="text",
50
- title="ืžืžื™ืจ ืื•ื“ื™ื•/ื•ื™ื“ืื• ืœืกื™ื›ื•ื",
51
- description="ื”ืขืœื” ืงื•ื‘ืฅ ืื•ื“ื™ื• ืื• ื•ื™ื“ืื• ืฉืœ ืžืจืฆื” ื•ืงื‘ืœ ืกื™ื›ื•ื ืงืฆืจ ืฉืœ ื”ืชื•ื›ืŸ."
52
  )
53
 
54
  if __name__ == "__main__":
 
11
  # ื”ื’ื“ืจืช pipeline ืœืกื™ื›ื•ื
12
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
13
 
14
+ def transcribe_and_summarize(file_path):
15
  try:
16
  # ื‘ื“ื™ืงื” ืื ื”ืงื•ื‘ืฅ ื”ื•ื ื•ื™ื“ืื• ื•ื”ืžืจืช ื•ื™ื“ืื• ืœืื•ื“ื™ื• ื‘ืžื™ื“ืช ื”ืฆื•ืจืš
17
  if file_path.endswith((".mp4", ".mov", ".avi", ".mkv")):
 
30
  if audio_file != file_path:
31
  os.remove(audio_file)
32
 
33
+ return transcript, summary
34
 
35
  except Exception as e:
36
+ return f"ืฉื’ื™ืื” ื‘ืขื™ื‘ื•ื“ ื”ืงื•ื‘ืฅ: {str(e)}", ""
37
 
38
  def convert_video_to_audio(video_file):
39
  # ื™ืฆื™ืจืช ืงื•ื‘ืฅ ืื•ื“ื™ื• ื–ืžื ื™
 
44
 
45
  # ื”ื’ื“ืจืช ืžืžืฉืง Gradio
46
  interface = gr.Interface(
47
+ fn=transcribe_and_summarize,
48
  inputs=gr.Audio(type="filepath"),
49
+ outputs=["text", "text"], # ืคืœื˜ ื›ืคื•ืœ: ืชืžืœื•ืœ ื•ืกื™ื›ื•ื
50
+ title="ืžืžื™ืจ ืื•ื“ื™ื•/ื•ื™ื“ืื• ืœืชืžืœื•ืœ ื•ืกื™ื›ื•ื",
51
+ description="ื”ืขืœื” ืงื•ื‘ืฅ ืื•ื“ื™ื• ืื• ื•ื™ื“ืื• ืฉืœ ืžืจืฆื” ื•ืงื‘ืœ ืชืžืœื•ืœ ืžืœื ื•ืกื™ื›ื•ื ืงืฆืจ ืฉืœ ื”ืชื•ื›ืŸ."
52
  )
53
 
54
  if __name__ == "__main__":