Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,22 @@ def save_image(image, image_count):
|
|
27 |
cv2.imwrite(filename, cv2_img)
|
28 |
return filename
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
# Main Function
|
33 |
def main():
|
@@ -70,7 +85,15 @@ def main():
|
|
70 |
|
71 |
# Chord Sheet Section
|
72 |
with col2:
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
# Trigger a rerun only when the snapshot interval is reached
|
76 |
if 'last_captured' in st.session_state and time.time() - st.session_state['last_captured'] > snapshot_interval:
|
|
|
27 |
cv2.imwrite(filename, cv2_img)
|
28 |
return filename
|
29 |
|
30 |
+
def get_image_base64(image_path):
|
31 |
+
with open(image_path, "rb") as image_file:
|
32 |
+
return base64.b64encode(image_file.read()).decode()
|
33 |
+
|
34 |
+
# Function Definitions for Chord Sheet Feature
|
35 |
+
def process_line(line):
|
36 |
+
if re.search(r'\b[A-G][#b]?m?\b', line):
|
37 |
+
line = re.sub(r'\b([A-G][#b]?m?)\b', r"<img src='\1.png' style='height:20px;'>", line)
|
38 |
+
return line
|
39 |
+
|
40 |
+
def process_chord_sheet(chord_sheet):
|
41 |
+
processed_lines = []
|
42 |
+
for line in chord_sheet.split('\n'):
|
43 |
+
processed_line = process_line(line)
|
44 |
+
processed_lines.append(processed_line)
|
45 |
+
return '<br>'.join(processed_lines)
|
46 |
|
47 |
# Main Function
|
48 |
def main():
|
|
|
85 |
|
86 |
# Chord Sheet Section
|
87 |
with col2:
|
88 |
+
st.title("Chord Sheet Manager")
|
89 |
+
|
90 |
+
all_files = [f for f in glob.glob("*.txt") if ' by ' in f]
|
91 |
+
selected_file = st.selectbox("Choose a Song:", all_files)
|
92 |
+
|
93 |
+
if selected_file:
|
94 |
+
with open(selected_file, 'r', encoding='utf-8') as file:
|
95 |
+
chord_sheet = file.read()
|
96 |
+
st.markdown(process_chord_sheet(chord_sheet), unsafe_allow_html=True)
|
97 |
|
98 |
# Trigger a rerun only when the snapshot interval is reached
|
99 |
if 'last_captured' in st.session_state and time.time() - st.session_state['last_captured'] > snapshot_interval:
|