Spaces:
Running
Running
import gradio as gr | |
import whisper | |
import os | |
os.system("pip install git+https://github.com/openai/whisper.git") | |
model = whisper.load_model("medium") | |
# main処理 | |
def main(URL): | |
video_path = youtube_dl(URL) | |
text = transcript(video_path) | |
return text | |
# Whisperを使用した文字起こし | |
def transcript(video_path): | |
result = model.transcribe(video_path) | |
return result["text"] | |
# 動画をダウンロードする | |
def youtube_dl(URL): | |
# 動画をダウンロードする | |
os.system(f"yt-dlp -f best -v {URL} -o target.mp4") | |
# ダウンロードした動画のパス | |
video_path = os.path.join(os.path.dirname(__file__), "target.mp4") | |
return video_path | |
demo = gr.Interface(fn = main, | |
inputs = "text", | |
outputs = "text") | |
if __name__ == "__main__": | |
demo.launch() | |