englissi commited on
Commit
1cb6071
Β·
verified Β·
1 Parent(s): b1321fc

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -51
app.py DELETED
@@ -1,51 +0,0 @@
1
- import gradio as gr
2
- import whisper
3
- import os
4
- from pytube import YouTube
5
- from moviepy.editor import VideoFileClip
6
-
7
- model = whisper.load_model("base")
8
-
9
- def download_youtube_audio(url):
10
- yt = YouTube(url)
11
- stream = yt.streams.filter(only_audio=True).first()
12
- audio_file = stream.download(filename="yt_audio.mp4")
13
- return audio_file
14
-
15
- def transcribe_from_file(file):
16
- filename, ext = os.path.splitext(file)
17
- if ext == ".mp4":
18
- video = VideoFileClip(file)
19
- audio_path = filename + ".mp3"
20
- video.audio.write_audiofile(audio_path)
21
- result = model.transcribe(audio_path)
22
- os.remove(audio_path)
23
- else:
24
- result = model.transcribe(file)
25
- return result["text"]
26
-
27
- def transcribe_combined(file, url):
28
- if url:
29
- try:
30
- downloaded = download_youtube_audio(url)
31
- return transcribe_from_file(downloaded)
32
- except Exception as e:
33
- return f"❌ 유튜브 λ‹€μš΄λ‘œλ“œ μ‹€νŒ¨: {str(e)}"
34
- elif file:
35
- return transcribe_from_file(file)
36
- else:
37
- return "⚠️ νŒŒμΌμ΄λ‚˜ URL 쀑 ν•˜λ‚˜λ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”."
38
-
39
- demo = gr.Interface(
40
- fn=transcribe_combined,
41
- inputs=[
42
- gr.File(label="🎬 파일 μ—…λ‘œλ“œ (선택)", file_types=[".mp3", ".wav", ".mp4"]),
43
- gr.Textbox(label="πŸ“Ž YouTube 링크 (선택)", placeholder="https://youtu.be/...")
44
- ],
45
- outputs="text",
46
- title="🎧 Whisper 전사기 + YouTube 지원",
47
- description="mp4/mp3/wav νŒŒμΌμ„ μ—…λ‘œλ“œν•˜κ±°λ‚˜ YouTube μ˜μƒ μ£Όμ†Œλ₯Ό λΆ™μ—¬λ„£μ–΄ ν…μŠ€νŠΈλ‘œ μ „μ‚¬ν•˜μ„Έμš”!",
48
- allow_flagging="never"
49
- )
50
-
51
- demo.launch()