Spaces:
Runtime error
Runtime error
File size: 1,051 Bytes
cb79139 b4a24a2 cb79139 |
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 29 30 |
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) |