import gradio as gr from fastai.vision.all import * from fastaudio.core.all import * def get_x(df): return df.path def get_y(df): return df.pattern learn = load_learner('xresnet50_pitch3.pkl') labels = learn.dls.vocab def predict(Record, Upload): if Upload: path = Upload else: path = Record pred,pred_idx,probs = learn.predict(str(path)) return {labels[i]: float(probs[i]) for i in range(len(labels))} title = "Japanese Pitch Accent Pattern Detector" description = "This model will predict pitch accent pattern of a word based on the recording of its pronunciation." article="

Blog

" interpretation='default' examples = [['代わる.mp3'],['大丈夫な.mp3'],['熱くない.mp3']] enable_queue=True gr.Interface(fn=predict,inputs=[gr.inputs.Audio(source='microphone', type='filepath', optional=True), gr.inputs.Audio(source='upload', type='filepath', optional=True)] ,outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples).launch(debug=True,share=True,enable_queue=enable_queue)