import gradio as gr import numpy as np from SpeechIntent import SpeechTranslate from scipy.io.wavfile import write speech_intent = SpeechTranslate() def numpy_to_wavfile(audio,name="audio.wav"): write(name, audio[0], audio[1]) return name def reply_intent(audioarray,intent_labels): print(intent_labels,audioarray) audiofile = numpy_to_wavfile(audioarray) reply_audio,intent = speech_intent.process(audiofile,intent_labels) numpy_to_wavfile((reply_audio,22050),"output.wav") return reply_audio,intent reply_intent_interface = gr.Interface( fn=reply_intent, 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")], outputs=[gr.Audio(type="numpy",label="Reply"),gr.Textbox(label="Intent")], title="Auto-intent", description="Auto-intent", allow_flagging=False, allow_screenshot=False, ) reply_intent_interface.launch(share=True)