File size: 935 Bytes
ffd5eab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr

model = gr.Interface.load("huggingface/pyannote/voice-activity-detection")

#load input file and resample to 16kHz
def load_data(path):
    speech, sampling_rate = librosa.load(path)
    if len(speech.shape) > 1:
        speech = speech[:,0] + speech[:,1]
    if sampling_rate != 16000:
        speech = librosa.resample(speech, sampling_rate,16000)
    return speech
    
def inference(path):
    audio = load_data(path)

inputs = gr.inputs.Audio(label="Input Audio", type="filepath", source="microphone")
outputs = gr.outputs.Label(type="auto", label = "Voice timestamps")
title = "Voice Activity Detection"
description = "Record or upload an audio file and detected human voices will be timestamped."
article = "<a href = 'pyannote, https://github.com/pyannote/pyannote-audio"

gr.Interface(inference, inputs, outputs, title=title, description=description, article=article, theme="dark").launch(debug=True)