dodoya1 commited on
Commit
619d335
โ€ข
1 Parent(s): 7ad4594

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -4,28 +4,31 @@ import os
4
 
5
  model = whisper.load_model("medium")
6
 
7
- # mainๅ‡ฆ็†
8
  def main(URL):
9
  video_path = youtube_dl(URL)
10
  text = transcript(video_path)
11
  return text
12
 
13
- # Whisperใ‚’ไฝฟ็”จใ—ใŸๆ–‡ๅญ—่ตทใ“ใ—
14
  def transcript(video_path):
15
  result = model.transcribe(video_path)
16
  return result["text"]
17
 
18
- # ๅ‹•็”ปใ‚’ใƒ€ใ‚ฆใƒณใƒญใƒผใƒ‰ใ™ใ‚‹
19
  def youtube_dl(URL):
20
- # ๅ‹•็”ปใ‚’ใƒ€ใ‚ฆใƒณใƒญใƒผใƒ‰ใ™ใ‚‹
21
  os.system(f"yt-dlp -f best -v {URL} -o target.mp4")
22
- # ใƒ€ใ‚ฆใƒณใƒญใƒผใƒ‰ใ—ใŸๅ‹•็”ปใฎใƒ‘ใ‚น
23
  video_path = os.path.join(os.path.dirname(__file__), "target.mp4")
24
- return video_path
 
 
 
 
25
 
26
  demo = gr.Interface(fn = main,
27
- inputs = "text",
28
- outputs = "text")
29
 
30
  if __name__ == "__main__":
31
  demo.launch()
 
4
 
5
  model = whisper.load_model("medium")
6
 
7
+ # main processing
8
  def main(URL):
9
  video_path = youtube_dl(URL)
10
  text = transcript(video_path)
11
  return text
12
 
13
+ # Transcribe text using Whisper
14
  def transcript(video_path):
15
  result = model.transcribe(video_path)
16
  return result["text"]
17
 
18
+ # Download the video
19
  def youtube_dl(URL):
20
+ # Download the video
21
  os.system(f"yt-dlp -f best -v {URL} -o target.mp4")
22
+ # Path of downloaded video
23
  video_path = os.path.join(os.path.dirname(__file__), "target.mp4")
24
+ # Check if the video is downloaded successfully
25
+ if os.path.exists(video_path):
26
+ return video_path
27
+ else:
28
+ raise ValueError("Video download failed")
29
 
30
  demo = gr.Interface(fn = main,
31
+ inputs = "text", outputs = "text")
 
32
 
33
  if __name__ == "__main__":
34
  demo.launch()