Update app.py
Browse files
app.py
CHANGED
@@ -43,32 +43,27 @@ def load_song_file(filename):
|
|
43 |
processed_sheet = process_chord_sheet(chord_sheet)
|
44 |
st.markdown(processed_sheet, unsafe_allow_html=True)
|
45 |
|
|
|
46 |
# Automatic save function
|
47 |
def auto_save():
|
48 |
song_name = st.session_state['song_name']
|
49 |
artist_name = st.session_state['artist_name']
|
50 |
chord_sheet = st.session_state['chord_sheet']
|
51 |
|
52 |
-
# Display the character count
|
53 |
-
st.sidebar.write("Character Count:", len(chord_sheet))
|
54 |
-
|
55 |
if song_name and artist_name:
|
56 |
filename = f"{song_name} by {artist_name}.txt".replace(" ", "_")
|
57 |
with open(filename, "w") as file:
|
58 |
file.write(chord_sheet)
|
59 |
-
|
|
|
|
|
60 |
|
61 |
def main():
|
62 |
st.title('🎵 Song Files')
|
63 |
with st.expander("Select Song File", expanded=True):
|
64 |
all_files = [f for f in glob.glob("*.txt") if ' by ' in f]
|
65 |
selected_file = st.selectbox("Choose a file", all_files)
|
66 |
-
|
67 |
-
song_name, artist_name = os.path.splitext(selected_file)[0].split(' by ')
|
68 |
-
song_name = song_name.replace("_", " ")
|
69 |
-
artist_name = artist_name.replace("_", " ")
|
70 |
-
else:
|
71 |
-
song_name, artist_name = "", ""
|
72 |
col1, col2 = st.columns([4, 1])
|
73 |
with col1:
|
74 |
song_name_input = st.text_input("🎵 Song Name", key='song_name')
|
@@ -83,6 +78,10 @@ def main():
|
|
83 |
else:
|
84 |
chord_sheet_area = st.text_area("Chord Sheet", height=300, key='chord_sheet', on_change=auto_save)
|
85 |
|
|
|
|
|
|
|
|
|
86 |
# Save functionality
|
87 |
if st.button("💾 Save", key="save_song"):
|
88 |
if song_name_input and artist_name_input:
|
|
|
43 |
processed_sheet = process_chord_sheet(chord_sheet)
|
44 |
st.markdown(processed_sheet, unsafe_allow_html=True)
|
45 |
|
46 |
+
|
47 |
# Automatic save function
|
48 |
def auto_save():
|
49 |
song_name = st.session_state['song_name']
|
50 |
artist_name = st.session_state['artist_name']
|
51 |
chord_sheet = st.session_state['chord_sheet']
|
52 |
|
|
|
|
|
|
|
53 |
if song_name and artist_name:
|
54 |
filename = f"{song_name} by {artist_name}.txt".replace(" ", "_")
|
55 |
with open(filename, "w") as file:
|
56 |
file.write(chord_sheet)
|
57 |
+
|
58 |
+
# Display the character count below the text area
|
59 |
+
st.session_state['char_count'] = len(chord_sheet)
|
60 |
|
61 |
def main():
|
62 |
st.title('🎵 Song Files')
|
63 |
with st.expander("Select Song File", expanded=True):
|
64 |
all_files = [f for f in glob.glob("*.txt") if ' by ' in f]
|
65 |
selected_file = st.selectbox("Choose a file", all_files)
|
66 |
+
|
|
|
|
|
|
|
|
|
|
|
67 |
col1, col2 = st.columns([4, 1])
|
68 |
with col1:
|
69 |
song_name_input = st.text_input("🎵 Song Name", key='song_name')
|
|
|
78 |
else:
|
79 |
chord_sheet_area = st.text_area("Chord Sheet", height=300, key='chord_sheet', on_change=auto_save)
|
80 |
|
81 |
+
# Display the character count below the text area
|
82 |
+
char_count_msg = f"Character Count: {st.session_state.get('char_count', 0)}"
|
83 |
+
st.write(char_count_msg)
|
84 |
+
|
85 |
# Save functionality
|
86 |
if st.button("💾 Save", key="save_song"):
|
87 |
if song_name_input and artist_name_input:
|