Spaces:
Running
Running
Upload 3 files
Browse files- README.md +22 -12
- app.py +31 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 機能
|
2 |
+
|
3 |
+
YouTubeのURLを入力すると、そのYouTube動画の音声を文字起こしするアプリです。
|
4 |
+
|
5 |
+
# やること
|
6 |
+
|
7 |
+
* 画面設計をする。
|
8 |
+
* Hugging Faceにデプロイする。
|
9 |
+
|
10 |
+
# 参考文献
|
11 |
+
|
12 |
+
https://gradio.app/
|
13 |
+
|
14 |
+
https://ai-research-collection.com/gradio-cal/
|
15 |
+
|
16 |
+
https://ai-research-collection.com/gradio-image-classification/
|
17 |
+
|
18 |
+
https://aiacademy.jp/media/?p=3469
|
19 |
+
|
20 |
+
https://gihyo.jp/article/2023/04/programming-with-chatgpt-02
|
21 |
+
|
22 |
+
https://gradio.app/docs/
|
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import whisper
|
3 |
+
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()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
whisper
|