baguioni commited on
Commit
ffd5eab
·
1 Parent(s): 808a24e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ model = gr.Interface.load("huggingface/pyannote/voice-activity-detection")
4
+
5
+ #load input file and resample to 16kHz
6
+ def load_data(path):
7
+ speech, sampling_rate = librosa.load(path)
8
+ if len(speech.shape) > 1:
9
+ speech = speech[:,0] + speech[:,1]
10
+ if sampling_rate != 16000:
11
+ speech = librosa.resample(speech, sampling_rate,16000)
12
+ return speech
13
+
14
+ def inference(path):
15
+ audio = load_data(path)
16
+
17
+ inputs = gr.inputs.Audio(label="Input Audio", type="filepath", source="microphone")
18
+ outputs = gr.outputs.Label(type="auto", label = "Voice timestamps")
19
+ title = "Voice Activity Detection"
20
+ description = "Record or upload an audio file and detected human voices will be timestamped."
21
+ article = "<a href = 'pyannote, https://github.com/pyannote/pyannote-audio"
22
+
23
+ gr.Interface(inference, inputs, outputs, title=title, description=description, article=article, theme="dark").launch(debug=True)
24
+
25
+
26
+
27
+