Spaces:
Sleeping
Sleeping
File size: 776 Bytes
ab6d074 |
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 |
import gradio as gr
import pandas as pd
# Load your dataset from HF Dataset repo
url = "https://huggingface.co/datasets/SleepyTerr/RB_music/resolve/main/rnb_dataset.csv"
df = pd.read_csv(url)
# Define a simple API function
def get_song(index: int):
if index < 0 or index >= len(df):
return "Invalid index"
song = df.iloc[index]
return {
"Song": song['Song'],
"Artist": song['Artist'],
"Album": song['Album'],
"Release Year": song['Release Year'],
"Monthly Listeners": song['Monthly Listeners']
}
# Gradio interface
api = gr.Interface(
fn=get_song,
inputs=gr.Number(label="Song Index"),
outputs="json",
title="R&B Music Dataset API",
description="Returns song info by index"
)
api.launch() |