File size: 1,703 Bytes
03e9693
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 !**")