clement-pages commited on
Commit
1989564
·
1 Parent(s): 5db9cc9

update space app

Browse files
Files changed (1) hide show
  1. app.py +53 -43
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(pipeline: Pipeline, audio):
9
  """Apply specified pipeline on the indicated audio file"""
 
10
  annotations = pipeline(audio)
11
 
12
- return ((audio, annotations), (audio, annotations))
13
-
14
-
15
- def update_annotations(data):
16
- return rttm.on_edit(data)
17
 
18
 
19
  with gr.Blocks() as demo:
20
- gr.Markdown(
21
- "[Gryannote](): The [pyannote](https://github.com/pyannote/pyannote-audio) audio labeling tool"
22
- )
 
 
 
 
 
 
23
 
24
- pipeline_selector = PipelineSelector(token=os.environ["HF_TOKEN"])
25
- pipeline_selector.select(
26
- fn=pipeline_selector.on_select,
27
- inputs=pipeline_selector,
28
- outputs=pipeline_selector,
29
- preprocess=False,
30
- postprocess=False,
31
- )
32
- pipeline_selector.change(
33
- fn=pipeline_selector.on_change,
34
- inputs=pipeline_selector,
35
- outputs=pipeline_selector,
36
- preprocess=False,
37
- postprocess=False,
38
- )
39
- audio_labeling = AudioLabeling(
40
- type="filepath",
41
- interactive=True,
42
- )
43
 
44
- run_btn = gr.Button("Run pipeline")
45
-
46
- rttm = RTTM()
47
-
48
- audio_labeling.edit(
49
- fn=update_annotations,
50
- inputs=audio_labeling,
51
- outputs=rttm,
52
- preprocess=False,
53
- postprocess=False,
54
- )
 
 
 
 
 
 
 
 
 
55
 
56
  run_btn.click(
57
  fn=apply_pipeline,
58
- inputs=[pipeline_selector, audio_labeling],
59
- outputs=[audio_labeling, rttm],
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