Spaces:
Sleeping
Sleeping
import requests | |
import pandas as pd | |
import streamlit as st | |
from io import StringIO | |
# URL of the markdown table | |
url = "https://huggingface.co/Lenylvt/NoCopyrightMusic_for_AIModelExamples/resolve/main/Sounds_Table_Markdown.md?download=true" | |
# Download the markdown content | |
response = requests.get(url) | |
markdown_content = response.text | |
# Find the start and end of the table in the markdown content | |
start_of_table = markdown_content.find("|") | |
end_of_table = markdown_content.find("\n\n", start_of_table) | |
table_content = markdown_content[start_of_table:end_of_table] | |
# Convert the markdown table to a DataFrame | |
df = pd.read_table(StringIO(table_content), sep="\s*\|\s*", engine='python') | |
df.columns = df.columns.str.strip() | |
# Extract URLs from markdown links | |
def extract_url(md_link): | |
start = md_link.find("(") + 1 | |
end = md_link.find(")", start) | |
return md_link[start:end] | |
for column in ['Full Version', 'Instrumental Version', 'Vocals Version']: | |
df[column] = df[column].apply(extract_url) | |
# Streamlit app layout | |
st.title("πΌ Music Player") | |
st.markdown("**Select a track and its version to play.** You can find all music [here](https://huggingface.co/Lenylvt/NoCopyrightMusic_for_AIModelExamples) π") | |
# Dropdown to select music | |
music_name = st.selectbox("Select Music π΅", df['Music Name'].tolist()) | |
# Radio buttons to select version | |
version = st.radio("Version ποΈ", ['Full Version', 'Instrumental Version', 'Vocals Version']) | |
# Find and display the selected music | |
if st.button('Play Music'): | |
row = df[df['Music Name'].str.strip() == music_name].iloc[0] | |
music_url = row[version] | |
st.audio(music_url) | |
st.markdown("**Click on three dot to download it !**") | |