File size: 891 Bytes
2c46407 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
import whisper
import os
from moviepy.editor import VideoFileClip
model = whisper.load_model("base")
def transcribe_media(file):
# νμ₯μ νμΈ
filename, ext = os.path.splitext(file)
# mp4μΈ κ²½μ°: μ€λμ€ μΆμΆ
if ext == ".mp4":
video = VideoFileClip(file)
audio_path = filename + ".mp3"
video.audio.write_audiofile(audio_path)
result = model.transcribe(audio_path)
os.remove(audio_path) # μμ νμΌ μ 리
else:
result = model.transcribe(file)
return result["text"]
demo = gr.Interface(
fn=transcribe_media,
inputs=gr.File(label="π¬ mp4 / mp3 / wav νμΌ μ
λ‘λ"),
outputs="text",
title="π€ Whisper μμ± μ μ¬κΈ°",
description="mp4 μμ λλ mp3/wav μμ± νμΌμ ν
μ€νΈλ‘ λ³νν©λλ€.",
allow_flagging="never"
)
demo.launch()
|