Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app (1).py +47 -0
- requirements (1).txt +3 -0
app (1).py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import pandas as pd
|
3 |
+
import streamlit as st
|
4 |
+
from io import StringIO
|
5 |
+
|
6 |
+
# URL of the markdown table
|
7 |
+
url = "https://huggingface.co/Lenylvt/NoCopyrightMusic_for_AIModelExamples/resolve/main/Sounds_Table_Markdown.md?download=true"
|
8 |
+
|
9 |
+
# Download the markdown content
|
10 |
+
response = requests.get(url)
|
11 |
+
markdown_content = response.text
|
12 |
+
|
13 |
+
# Find the start and end of the table in the markdown content
|
14 |
+
start_of_table = markdown_content.find("|")
|
15 |
+
end_of_table = markdown_content.find("\n\n", start_of_table)
|
16 |
+
table_content = markdown_content[start_of_table:end_of_table]
|
17 |
+
|
18 |
+
# Convert the markdown table to a DataFrame
|
19 |
+
df = pd.read_table(StringIO(table_content), sep="\s*\|\s*", engine='python')
|
20 |
+
df.columns = df.columns.str.strip()
|
21 |
+
|
22 |
+
# Extract URLs from markdown links
|
23 |
+
def extract_url(md_link):
|
24 |
+
start = md_link.find("(") + 1
|
25 |
+
end = md_link.find(")", start)
|
26 |
+
return md_link[start:end]
|
27 |
+
|
28 |
+
for column in ['Full Version', 'Instrumental Version', 'Vocals Version']:
|
29 |
+
df[column] = df[column].apply(extract_url)
|
30 |
+
|
31 |
+
# Streamlit app layout
|
32 |
+
st.title("πΌ Music Player")
|
33 |
+
st.markdown("**Select a track and its version to play.** You can find all music [here](https://huggingface.co/Lenylvt/NoCopyrightMusic_for_AIModelExamples) π")
|
34 |
+
|
35 |
+
# Dropdown to select music
|
36 |
+
music_name = st.selectbox("Select Music π΅", df['Music Name'].tolist())
|
37 |
+
|
38 |
+
# Radio buttons to select version
|
39 |
+
version = st.radio("Version ποΈ", ['Full Version', 'Instrumental Version', 'Vocals Version'])
|
40 |
+
|
41 |
+
# Find and display the selected music
|
42 |
+
if st.button('Play Music'):
|
43 |
+
row = df[df['Music Name'].str.strip() == music_name].iloc[0]
|
44 |
+
music_url = row[version]
|
45 |
+
st.audio(music_url)
|
46 |
+
st.markdown("**Click on three dot to download it !**")
|
47 |
+
|
requirements (1).txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
pandas
|
3 |
+
requests
|