|
import streamlit as st |
|
import re |
|
|
|
|
|
def process_line(line): |
|
|
|
if re.search(r'\b[A-G][#b]?m?\b', line): |
|
|
|
line = re.sub(r'\b([A-G][#b]?m?)\b', r"<img src='\1.png' style='height:20px;'>", line) |
|
return line |
|
|
|
|
|
def process_chord_sheet(chord_sheet): |
|
processed_lines = [] |
|
for line in chord_sheet.split('\n'): |
|
processed_line = process_line(line) |
|
processed_lines.append(processed_line) |
|
return '<br>'.join(processed_lines) |
|
|
|
|
|
def main(): |
|
st.title('Chord Sheet Processor') |
|
|
|
|
|
chord_sheet_input = st.text_area("Enter your chord sheet here:", height=300) |
|
|
|
if st.button('Process Chord Sheet'): |
|
if chord_sheet_input: |
|
|
|
processed_sheet = process_chord_sheet(chord_sheet_input) |
|
|
|
st.markdown(processed_sheet, unsafe_allow_html=True) |
|
else: |
|
st.error("Please input a chord sheet to process.") |
|
|
|
if __name__ == '__main__': |
|
main() |
|
|