Spaces:
Runtime error
Runtime error
File size: 1,266 Bytes
30f32d0 ed060a2 42031f0 a913d8c 30f32d0 1654da2 c67e62e 1654da2 dfa07fa 30f32d0 c18bef7 30f32d0 2231179 30f32d0 2231179 30f32d0 45ece48 30f32d0 8a6918f |
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 31 32 33 34 35 36 37 |
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
spec,pred,pred_idx,probs = learn.predict(str(path), with_input=True)
return [{labels[i]: float(probs[i]) for i in range(len(labels))}, show_image(spec)]
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="<p style='text-align: center'><a href='mizoru.github.io/blog' target='_blank'>Blog</a></p>"
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), gr.outputs.Image(type="plot", label='Spectrogram')], title=title,description=description,article=article,examples=examples).launch(debug=True,share=True,enable_queue=enable_queue)
|