File size: 662 Bytes
804a126
5ce55d8
b0df8f4
 
804a126
124b67b
804a126
90883a0
6fc1be7
93e160d
124b67b
14aba69
 
 
79b2d0d
e91fc04
e220118
14aba69
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from datasets import load_dataset, Audio
import torch
from transformers import pipeline

pipeline = pipeline("audio-classification", model="DanielDBGC/my_awesome_lang_class_mind_model")

def predict(input_sound):
    print(input_sound)
    predictions = pipeline(input_sound[1])
    return {p["label"]: p["score"] for p in predictions} 

gradio_app = gr.Interface(
    predict,
    inputs= gr.Audio(label="Record or upload someone speaking!", sources=['upload', 'microphone'], type = 'numpy')[1],
    outputs=[gr.Label(label="Result", num_top_classes=3)],
    title="Guess the language!",
)

if __name__ == "__main__":
    gradio_app.launch()