Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
1989564
1
Parent(s):
5db9cc9
update space app
Browse files
app.py
CHANGED
@@ -1,62 +1,72 @@
|
|
1 |
import gradio as gr
|
2 |
from gryannote_audio import AudioLabeling
|
3 |
-
from gryannote_pipeline import PipelineSelector
|
4 |
-
from gryannote_rttm import RTTM
|
5 |
from pyannote.audio import Pipeline
|
6 |
import os
|
7 |
|
8 |
-
def apply_pipeline(
|
9 |
"""Apply specified pipeline on the indicated audio file"""
|
|
|
10 |
annotations = pipeline(audio)
|
11 |
|
12 |
-
return (
|
13 |
-
|
14 |
-
|
15 |
-
def update_annotations(data):
|
16 |
-
return rttm.on_edit(data)
|
17 |
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
-
gr.
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
run_btn.click(
|
57 |
fn=apply_pipeline,
|
58 |
-
inputs=
|
59 |
-
outputs=
|
60 |
)
|
61 |
|
62 |
|
|
|
1 |
import gradio as gr
|
2 |
from gryannote_audio import AudioLabeling
|
|
|
|
|
3 |
from pyannote.audio import Pipeline
|
4 |
import os
|
5 |
|
6 |
+
def apply_pipeline(audio):
|
7 |
"""Apply specified pipeline on the indicated audio file"""
|
8 |
+
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", use_auth_token=os.environ["HF_TOKEN"])
|
9 |
annotations = pipeline(audio)
|
10 |
|
11 |
+
return (audio, annotations)
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
with gr.Blocks() as demo:
|
15 |
+
with gr.Row(equal_height=True):
|
16 |
+
with gr.Row():
|
17 |
+
with gr.Column(scale=1):
|
18 |
+
gr.Markdown(
|
19 |
+
'<a href="https://github.com/clement-pages/gryannote"><img src="https://repository-images.githubusercontent.com/744648524/e841cef0-fbd9-45b0-9bce-536a1822c7b1" alt="gryannote logo" width="220"/></a>',
|
20 |
+
)
|
21 |
+
with gr.Column(scale=6):
|
22 |
+
gr.Markdown('<h1 style="font-size: 3em;">gryannote</h1>')
|
23 |
+
gr.Markdown("<h2>Make the audio labeling process easier and faster! </h2>")
|
24 |
|
25 |
+
with gr.Row():
|
26 |
+
with gr.Column():
|
27 |
+
gr.Markdown(
|
28 |
+
"To use the component, start by loading or recording audio."
|
29 |
+
"Then apply the diarization pipeline (here [pyannote/speaker-diarization-3.1](https://huggingface.co/pyannote/speaker-diarization-3.1))"
|
30 |
+
"or double-click directly on the waveform. The annotations produced can be edited."
|
31 |
+
"You can also use keyboard shortcuts to speed things up!"
|
32 |
+
)
|
33 |
+
gr.Markdown()
|
34 |
+
gr.Markdown()
|
35 |
+
gr.Markdown('<img src="https://github.com/clement-pages/gryannote/blob/main/docs/assets/poster-interspeech.jpg?raw=true" alt="gryannote poster"/>')
|
36 |
+
with gr.Column():
|
37 |
+
audio_labeling = AudioLabeling(
|
38 |
+
type="filepath",
|
39 |
+
interactive=True,
|
40 |
+
)
|
41 |
+
gr.Markdown()
|
42 |
+
gr.Markdown()
|
43 |
+
run_btn = gr.Button("Run pipeline")
|
44 |
|
45 |
+
gr.Markdown(
|
46 |
+
"""| Shortcut | Action |
|
47 |
+
| --------------------------------------------- | --------------------------------------------------------------------- |
|
48 |
+
| `SPACE` | Toggle play / pause |
|
49 |
+
| `ENTER` | Create annotation at current time |
|
50 |
+
| `SHIFT + ENTER` | Split annotation at current time |
|
51 |
+
| `A`, `B`, `C`, ..., `Z` | Set active label. If there is a selected annotation, update its label |
|
52 |
+
| `LEFT` or `RIGHT` | Edit start time of selected annotation (if any) or move time cursor |
|
53 |
+
| `SHIFT + LEFT` or `SHIFT + RIGHT` | Same, but faster |
|
54 |
+
|`ALT + LEFT` or `ALT + RIGHT` | Edit end time of selected annotation |
|
55 |
+
| `SHIFT + ALT + LEFT` or `SHIFT + ALT + RIGHT` | Same, but faster |
|
56 |
+
| `TAB` | Select next annotation |
|
57 |
+
| `SHIFT + TAB` | Select previous annotation |
|
58 |
+
|`BACKSPACE` | Delete selected annotation and select the previous one |
|
59 |
+
|`DELETE` or `SHIFT + BACKSPACE` | Delete selected region and select the next one |
|
60 |
+
|`ESC` | Unselect selected annotation and / or label |
|
61 |
+
| `UP` or `DOWN` | Zoom in/out |
|
62 |
+
| `F2` | Open settings for the active label |
|
63 |
+
"""
|
64 |
+
)
|
65 |
|
66 |
run_btn.click(
|
67 |
fn=apply_pipeline,
|
68 |
+
inputs=audio_labeling,
|
69 |
+
outputs=audio_labeling,
|
70 |
)
|
71 |
|
72 |
|