gradio_ser / app.py
heloisy's picture
Create app.py
75954be
raw
history blame
772 Bytes
import gradio as gr
import time
def ser(audio):
temp_df = pd.DataFrame(columns=(['wav_file','label']))
temp_df.loc[0,'wav_file'] = audio
temp_df['label'] = 'unknow'
label,probs,scores = model_1.predict_df(temp_df)
return scores
ser_record = gr.Interface(
fn=ser,
title=None,
inputs= gr.Audio(source="microphone", type="filepath"),
interactive = True,
outputs="label",
description='Record audio')
ser_upload = gr.Interface(
fn=ser,
title=None,
inputs= gr.Audio(source="upload", type="filepath"),
interactive = True,
examples=ser_examples,
outputs="label",
description='Upload audio')
app = gr.TabbedInterface([ser_record, ser_upload], tab_names= ["Record audio", "Upload audio"])
app.launch()