Spaces:
Runtime error
Runtime error
File size: 2,103 Bytes
6a9646d fca1098 6a9646d fca1098 6a9646d 67a7ce9 6a9646d fca1098 6a9646d fca1098 6a9646d fca1098 85dcc7d fca1098 8a8996c |
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# STREAMLIT STUFF
import streamlit as st
from streamlit_tags import st_tags
# PYHTON STUFF
import json
# CUSTOM
from nlp.nlp import get_nearest_tags
f = open('NLP/tags.json') # OPEN JSON FILE
data = json.load(f) # LOAD DATA
f.close() # CLOSE FILE
# --------------------------- VARIABLES / MACROS
# SPLIT DATA
GENRE_TAGS = data['genre']
MOOD_TAGS = data['mood']
INSTRUMENT_TAGS = data['instrument']
MAX_TAGS = 3
# --------------------------- TITLE
st.title("FIRE COML FALL 2022 Audio Generation Model")
# --------------------------- MAIN
# SELECT TYPE OF GENERATION
option = st.selectbox("Select Generation type:", ("Sentence Based", "Tag Based"))
# SENTENCE BASED
if option == "Sentence Based":
input_sentence = st.text_input("Enter a description for a song you want to hear:")
# SUBMIT DESCRIPTION
if st.button("Submit Description"):
if input_sentence is not None and len(input_sentence) > 0:
st.write("Here is the generated audio: ")
st.write(input_sentence)
else:
st.write("Invalid Description")
# TAG BASED
else:
st.write("Enter Genre(s), Mood/Theme(s), and Instrument(s)")
instructions = "Press ENTER to add more"
genre = st_tags(
label = 'Enter Genre(s):',
text = instructions,
suggestions = GENRE_TAGS,
maxtags = MAX_TAGS,
key = '1'
)
mood = st_tags(
label = 'Enter Mood/Theme(s):',
text = instructions,
suggestions = MOOD_TAGS,
maxtags = MAX_TAGS,
key = '2'
)
instrument = st_tags(
label = 'Enter Instrument(s):',
text = instructions,
suggestions = INSTRUMENT_TAGS,
maxtags = MAX_TAGS,
key = '3'
)
# SUBMIT TAGS
if st.button("Submit Tags"):
st.write("Tags are:")
inp = genre + mood + instrument
st.write("Before: " + str(inp))
input = get_nearest_tags(inp)
st.write("After: " + str(input))
|