Spaces:
Runtime error
Runtime error
import gradio as gr | |
import numpy as np | |
from datasets import load_dataset | |
gtzan = load_dataset("marsyas/gtzan", split="train") | |
id2label = gtzan.features["genre"].int2str | |
def generate_audio(): | |
example = gtzan.shuffle()[0] | |
audio = example["audio"] | |
return ( | |
audio["sampling_rate"], | |
audio["array"], | |
), id2label(example["genre"]) | |
with gr.Blocks() as demo: | |
with gr.Column(): | |
for _ in range(4): | |
audio, label = generate_audio() | |
output = gr.Audio(audio, label=label) | |
demo.launch() |