Spaces:
Build error
Build error
Commit ·
3f16527
1
Parent(s): d4fdb85
Update App and add json
Browse files- app.py +71 -0
- tag_map.json +72 -0
app.py
CHANGED
|
@@ -1,3 +1,74 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_tags import st_tags
|
|
|
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_tags import st_tags
|
| 3 |
+
import json
|
| 4 |
|
| 5 |
+
|
| 6 |
+
f = open('tag_map.json') # OPEN JSON FILE
|
| 7 |
+
|
| 8 |
+
data = json.load(f) # LOAD DATA
|
| 9 |
+
|
| 10 |
+
f.close() # CLOSE FILE
|
| 11 |
+
|
| 12 |
+
# --------------------------- VARIABLES
|
| 13 |
+
|
| 14 |
+
# SPLIT DATA
|
| 15 |
+
GENRE_TAGS = data['genre']
|
| 16 |
+
MOOD_TAGS = data['mood']
|
| 17 |
+
INSTRUMENT_TAGS = data['instrument']
|
| 18 |
+
|
| 19 |
+
MAX_TAGS = 3
|
| 20 |
+
|
| 21 |
+
# --------------------------- TITLE
|
| 22 |
+
st.title("FIRE COML FALL 2022 Audio Generation Model")
|
| 23 |
+
|
| 24 |
+
# --------------------------- MAIN
|
| 25 |
+
# SELECT TYPE OF GENERATION
|
| 26 |
+
option = st.selectbox("Select Generation type:", ("Sentence Based", "Tag Based"))
|
| 27 |
+
|
| 28 |
+
# SENTENCE BASED
|
| 29 |
+
if option == "Sentence Based":
|
| 30 |
+
input_sentence = st.text_input("Enter a description for a song you want to hear:")
|
| 31 |
+
|
| 32 |
+
# SUBMIT DESCRIPTION
|
| 33 |
+
if st.button("Submit Description"):
|
| 34 |
+
if input_sentence is not None and len(input_sentence) > 0:
|
| 35 |
+
st.write("Here is the generated audio: ")
|
| 36 |
+
st.write(input_sentence)
|
| 37 |
+
else:
|
| 38 |
+
st.write("Invalid Description")
|
| 39 |
+
|
| 40 |
+
# TAG BASED
|
| 41 |
+
else:
|
| 42 |
+
st.write("Enter Genre(s), Mood/Theme(s), and Instrument(s)")
|
| 43 |
+
|
| 44 |
+
instructions = "Press enter to add more"
|
| 45 |
+
|
| 46 |
+
genre = st_tags(
|
| 47 |
+
label = '# Enter Genre(s):',
|
| 48 |
+
text = instructions,
|
| 49 |
+
suggestions = GENRE_TAGS,
|
| 50 |
+
maxtags = MAX_TAGS,
|
| 51 |
+
key = '1'
|
| 52 |
+
)
|
| 53 |
+
mood = st_tags(
|
| 54 |
+
label = '# Enter Mood/Theme(s):',
|
| 55 |
+
text = instructions,
|
| 56 |
+
suggestions = MOOD_TAGS,
|
| 57 |
+
maxtags = MAX_TAGS,
|
| 58 |
+
key = '2'
|
| 59 |
+
)
|
| 60 |
+
instrument = st_tags(
|
| 61 |
+
label = '# Enter Instrument(s):',
|
| 62 |
+
text = instructions,
|
| 63 |
+
suggestions = INSTRUMENT_TAGS,
|
| 64 |
+
maxtags = MAX_TAGS,
|
| 65 |
+
key = '3'
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
# SUBMIT TAGS
|
| 69 |
+
if st.button("Submit Tags"):
|
| 70 |
+
st.write("Tags are:")
|
| 71 |
+
# input = genre + ", " + mood + ", " + instrument
|
| 72 |
+
# input = input.split(", ")
|
| 73 |
+
input = genre + mood + instrument
|
| 74 |
+
st.write(str(input))
|
tag_map.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"genre": [
|
| 3 |
+
"punkrock",
|
| 4 |
+
"electronica",
|
| 5 |
+
"soundtrack",
|
| 6 |
+
"electronic",
|
| 7 |
+
"electronic",
|
| 8 |
+
"poprock",
|
| 9 |
+
"rockandroll",
|
| 10 |
+
"ambient",
|
| 11 |
+
"electropop",
|
| 12 |
+
"house",
|
| 13 |
+
"r&b",
|
| 14 |
+
"dance",
|
| 15 |
+
"folkpop",
|
| 16 |
+
"lounge",
|
| 17 |
+
"trance",
|
| 18 |
+
"progressive",
|
| 19 |
+
"classical",
|
| 20 |
+
"electronica",
|
| 21 |
+
"rap",
|
| 22 |
+
"techno",
|
| 23 |
+
"alternative",
|
| 24 |
+
"instrumentalhiphop"
|
| 25 |
+
],
|
| 26 |
+
"mood": [
|
| 27 |
+
"dreamy",
|
| 28 |
+
"emotional",
|
| 29 |
+
"film",
|
| 30 |
+
"energetic",
|
| 31 |
+
"inspirational",
|
| 32 |
+
"love",
|
| 33 |
+
"melancholic",
|
| 34 |
+
"relaxed",
|
| 35 |
+
"sad",
|
| 36 |
+
"romantic",
|
| 37 |
+
"hopeful",
|
| 38 |
+
"motivational",
|
| 39 |
+
"happy",
|
| 40 |
+
"sports",
|
| 41 |
+
"children",
|
| 42 |
+
"trailer",
|
| 43 |
+
"joyful",
|
| 44 |
+
"christmas",
|
| 45 |
+
"epic",
|
| 46 |
+
"dark",
|
| 47 |
+
"scifi",
|
| 48 |
+
"festive"
|
| 49 |
+
],
|
| 50 |
+
"instrument": [
|
| 51 |
+
"synthesizer",
|
| 52 |
+
"drums",
|
| 53 |
+
"strings",
|
| 54 |
+
"guitar",
|
| 55 |
+
"piano",
|
| 56 |
+
"saxophone",
|
| 57 |
+
"beat",
|
| 58 |
+
"violin",
|
| 59 |
+
"bell",
|
| 60 |
+
"percussion",
|
| 61 |
+
"choir",
|
| 62 |
+
"pad",
|
| 63 |
+
"flute",
|
| 64 |
+
"electricguitar",
|
| 65 |
+
"keyboard",
|
| 66 |
+
"horn",
|
| 67 |
+
"bongo",
|
| 68 |
+
"accordion",
|
| 69 |
+
"bass",
|
| 70 |
+
"clavier"
|
| 71 |
+
]
|
| 72 |
+
}
|