osyvokon commited on
Commit
b632993
1 Parent(s): 7165c71

Add missing file

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from fbeeper_hubert import HubertBeeper
4
+
5
+ BEEPER = HubertBeeper()
6
+
7
+
8
+ def greet(audio):
9
+ global BEEPER
10
+ sample_rate, wav = audio
11
+
12
+ # Gradio loads sound files as ints, the model expects normalized floats
13
+ wav = wav / 32768
14
+
15
+ # TODO: output sample_rate doesn't have to match input sample rate
16
+ text, result_wav = BEEPER.f_beep_waveform(wav, sample_rate)
17
+
18
+ result_wav = (result_wav * 32768).astype("int16")
19
+ return (text, (sample_rate, result_wav))
20
+
21
+
22
+ if __name__ == '__main__':
23
+ iface = gr.Interface(
24
+ fn=greet,
25
+ inputs="audio",
26
+ outputs=[
27
+ gr.outputs.Textbox(label="ASR output"),
28
+ gr.outputs.Audio(label="Censored speech"),
29
+ ],
30
+ examples=[["data/speech-short-16k.wav"], ["data/sample.wav"]],
31
+ server_port=7860,
32
+ )
33
+ iface.launch()