aliabd commited on
Commit
ec12968
·
1 Parent(s): b8a5176

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. README.md +8 -8
  2. files/a.mp4 +0 -0
  3. files/b.mp4 +0 -0
  4. files/s1.srt +29 -0
  5. files/s2.vtt +16 -0
  6. run.ipynb +1 -0
  7. run.py +32 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Video Subtitle 3-x
3
- emoji: 🏆
4
- colorFrom: red
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 4.3.0
8
- app_file: app.py
9
  pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: video_subtitle_3-x
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 3.50.1
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
files/a.mp4 ADDED
Binary file (130 kB). View file
 
files/b.mp4 ADDED
Binary file (261 kB). View file
 
files/s1.srt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 0
2
+ 0:00:00.000 --> 0:00:00.500
3
+ A
4
+
5
+ 1
6
+ 0:00:00.500 --> 0:00:01.000
7
+ B
8
+
9
+ 2
10
+ 0:00:01.000 --> 0:00:01.500
11
+ C
12
+
13
+ 3
14
+ 0:00:01.500 --> 0:00:02.000
15
+ D
16
+
17
+ 4
18
+ 0:00:02.000 --> 0:00:02.500
19
+ E
20
+
21
+ 5
22
+ 0:00:02.500 --> 0:00:03.000
23
+ F
24
+
25
+ 6
26
+ 0:00:03.000 --> 0:00:10.000
27
+ This is multiple line test.
28
+ Why did the tomato turn red? Because it saw the salad dressing.
29
+ In Africa, every 60 seconds a minute passes
files/s2.vtt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ WEBVTT
2
+
3
+ 0:00:00.000 --> 0:00:00.500
4
+
5
+
6
+ 0:00:00.500 --> 0:00:01.000
7
+
8
+
9
+ 0:00:01.000 --> 0:00:01.500
10
+
11
+
12
+ 0:00:01.500 --> 0:00:02.000
13
+
14
+
15
+ 0:00:02.000 --> 0:00:02.500
16
+ 中文測試
run.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: video_subtitle"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "os.mkdir('files')\n", "!wget -q -O files/a.mp4 https://github.com/gradio-app/gradio/raw/main/demo/video_subtitle/files/a.mp4\n", "!wget -q -O files/b.mp4 https://github.com/gradio-app/gradio/raw/main/demo/video_subtitle/files/b.mp4\n", "!wget -q -O files/s1.srt https://github.com/gradio-app/gradio/raw/main/demo/video_subtitle/files/s1.srt\n", "!wget -q -O files/s2.vtt https://github.com/gradio-app/gradio/raw/main/demo/video_subtitle/files/s2.vtt"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "\n", "a = os.path.join(os.path.abspath(''), \"files/a.mp4\") # Video\n", "b = os.path.join(os.path.abspath(''), \"files/b.mp4\") # Video\n", "s1 = os.path.join(os.path.abspath(''), \"files/s1.srt\") # Subtitle\n", "s2 = os.path.join(os.path.abspath(''), \"files/s2.vtt\") # Subtitle\n", "\n", "\n", "def video_demo(video, subtitle=None):\n", " if subtitle is None:\n", " return video\n", "\n", " return [video, subtitle.name]\n", "\n", "\n", "demo = gr.Interface(\n", " fn=video_demo,\n", " inputs=[\n", " gr.Video(type=\"file\", label=\"In\", interactive=True),\n", " gr.File(label=\"Subtitle\", file_types=[\".srt\", \".vtt\"]),\n", " ],\n", " outputs=gr.Video(label=\"Out\"),\n", " examples=[\n", " [a, s1],\n", " [b, s2],\n", " [a, None],\n", " ],\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ a = os.path.join(os.path.dirname(__file__), "files/a.mp4") # Video
5
+ b = os.path.join(os.path.dirname(__file__), "files/b.mp4") # Video
6
+ s1 = os.path.join(os.path.dirname(__file__), "files/s1.srt") # Subtitle
7
+ s2 = os.path.join(os.path.dirname(__file__), "files/s2.vtt") # Subtitle
8
+
9
+
10
+ def video_demo(video, subtitle=None):
11
+ if subtitle is None:
12
+ return video
13
+
14
+ return [video, subtitle.name]
15
+
16
+
17
+ demo = gr.Interface(
18
+ fn=video_demo,
19
+ inputs=[
20
+ gr.Video(type="file", label="In", interactive=True),
21
+ gr.File(label="Subtitle", file_types=[".srt", ".vtt"]),
22
+ ],
23
+ outputs=gr.Video(label="Out"),
24
+ examples=[
25
+ [a, s1],
26
+ [b, s2],
27
+ [a, None],
28
+ ],
29
+ )
30
+
31
+ if __name__ == "__main__":
32
+ demo.launch()