fathyshalab commited on
Commit
cb79139
·
1 Parent(s): f96f12d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from autoattendand.SpeechIntent import SpeechTranslate
4
+ from scipy.io.wavfile import write
5
+
6
+
7
+ speech_intent = SpeechTranslate()
8
+
9
+ def numpy_to_wavfile(audio,name="audio.wav"):
10
+ write(name, audio[0], audio[1])
11
+ return name
12
+
13
+ def reply_intent(audioarray,intent_labels):
14
+ print(intent_labels,audioarray)
15
+ audiofile = numpy_to_wavfile(audioarray)
16
+ reply_audio,intent = speech_intent.process(audiofile,intent_labels)
17
+ numpy_to_wavfile((reply_audio,22050),"output.wav")
18
+ return reply_audio,intent
19
+
20
+ reply_intent_interface = gr.Interface(
21
+ fn=reply_intent,
22
+ inputs=[gr.Audio(source="microphone",type="numpy",label="Audio"),gr.Textbox(["None","greeting","goodbye","thanks","yes","no","affirmative","negative","request","statement","question","command","other"],label="Intent")],
23
+ outputs=[gr.Audio(type="numpy",label="Reply"),gr.Textbox(label="Intent")],
24
+ title="Auto-intent",
25
+ description="Auto-intent",
26
+ allow_flagging=False,
27
+ allow_screenshot=False,
28
+ )
29
+
30
+ reply_intent_interface.launch(share=True)