Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- README.md +7 -7
- files/a.mp3 +3 -0
- files/b.mp3 +3 -0
- files/s1.srt +29 -0
- files/s2.vtt +16 -0
- run.ipynb +1 -0
- run.py +29 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
files/a.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
files/b.mp3 filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.
|
| 8 |
-
app_file:
|
| 9 |
pinned: false
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: audio_subtitle
|
| 4 |
+
emoji: 🔥
|
| 5 |
+
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
+
sdk_version: 5.45.0
|
| 9 |
+
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
+
hf_oauth: true
|
| 12 |
---
|
|
|
|
|
|
files/a.mp3
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6f96e13dfd69423d1c6cc883d6d0886fd8ae5c69f5a87661c5698ce8bf991b5
|
| 3 |
+
size 130399
|
files/b.mp3
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fc7e05ed802c94d74e9005e3bc53d5abfd36ab4b63be1602f6cfe697b789c418
|
| 3 |
+
size 261179
|
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: audio_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.mp3 https://github.com/gradio-app/gradio/raw/main/demo/audio_subtitle/files/a.mp3\n", "!wget -q -O files/b.mp3 https://github.com/gradio-app/gradio/raw/main/demo/audio_subtitle/files/b.mp3\n", "!wget -q -O files/s1.srt https://github.com/gradio-app/gradio/raw/main/demo/audio_subtitle/files/s1.srt\n", "!wget -q -O files/s2.vtt https://github.com/gradio-app/gradio/raw/main/demo/audio_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.mp3\")\n", "b = os.path.join(os.path.abspath(''), \"files/b.mp3\")\n", "s1 = os.path.join(os.path.abspath(''), \"files/s1.srt\")\n", "s2 = os.path.join(os.path.abspath(''), \"files/s2.vtt\")\n", "\n", "def add_subtitles_to_audio(audio, subtitles=None):\n", " if subtitles is None:\n", " return audio\n", " if subtitles is not None:\n", " return gr.Audio(label=\"Out\", value=audio, subtitles=subtitles.name)\n", "\n", "demo = gr.Interface(\n", " fn=add_subtitles_to_audio,\n", " inputs=[\n", " gr.Audio(label=\"In\", interactive=True),\n", " gr.File(label=\"Subtitle\", file_types=[\".srt\", \".vtt\"]),\n", " ],\n", " outputs=gr.Audio(label=\"Out\"),\n", " examples=[\n", " [a, s1],\n", " [b, s2],\n", " ],\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
a = os.path.join(os.path.dirname(__file__), "files/a.mp3")
|
| 5 |
+
b = os.path.join(os.path.dirname(__file__), "files/b.mp3")
|
| 6 |
+
s1 = os.path.join(os.path.dirname(__file__), "files/s1.srt")
|
| 7 |
+
s2 = os.path.join(os.path.dirname(__file__), "files/s2.vtt")
|
| 8 |
+
|
| 9 |
+
def add_subtitles_to_audio(audio, subtitles=None):
|
| 10 |
+
if subtitles is None:
|
| 11 |
+
return audio
|
| 12 |
+
if subtitles is not None:
|
| 13 |
+
return gr.Audio(label="Out", value=audio, subtitles=subtitles.name)
|
| 14 |
+
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=add_subtitles_to_audio,
|
| 17 |
+
inputs=[
|
| 18 |
+
gr.Audio(label="In", interactive=True),
|
| 19 |
+
gr.File(label="Subtitle", file_types=[".srt", ".vtt"]),
|
| 20 |
+
],
|
| 21 |
+
outputs=gr.Audio(label="Out"),
|
| 22 |
+
examples=[
|
| 23 |
+
[a, s1],
|
| 24 |
+
[b, s2],
|
| 25 |
+
],
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
demo.launch()
|