Japanese_pitch / app.py
mizoru's picture
Update app.py
a913d8c
raw
history blame
1.48 kB
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(path):
pred,pred_idx,probs = learn.predict(str(path))
return {labels[i]: float(probs[i]) for i in range(len(labels))}
print(predict('example1.mp3'))
title = "Japanese Pitch Accent Pattern Detector"
description = "Fire and Smoke classifier created with fastai. Created as a demo for Gradio and HuggingFace Spaces. Fire accidents are not uncommon and has catastrophic impact on the company both interms of social and financial terms. This application can be deployed on device and can work as 24X365 surveillance. This app classify an image into three classes. 1. Fire, 2. Smoke, 3. Neutral. Try your hand and check. For any general purpose, model file can be copied and used for the stated purpose"
article="<p style='text-align: center'><a href='https://github.com/mldurga/projects/blob/master/Fire_smoke_detector.ipynb' target='_blank'>Blog post</a></p>"
interpretation='default'
examples = ['example1.mp3']
enable_queue=True
gr.Interface(fn=predict,inputs=gr.inputs.Audio(source='microphone', type='filepath'),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,interpretation=interpretation,examples=examples).launch(debug=True,share=True,enable_queue=enable_queue)