Spaces:
Build error
Build error
| 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): | |
| dataset = load_dataset("PolyAI/minds14", name="en-US", split="train") | |
| dataset = dataset.cast_column("audio", Audio(sampling_rate=16000)) | |
| sampling_rate = dataset.features["audio"].sampling_rate | |
| audio_file = dataset[0]["audio"]["path"] | |
| predictions = pipeline(audio_file) | |
| 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'), | |
| outputs=[gr.Label(label="Result", num_top_classes=3)], | |
| title="Guess the language!", | |
| ) | |
| if __name__ == "__main__": | |
| gradio_app.launch() |