File size: 1,272 Bytes
a1de66d
 
00a404f
a1de66d
 
 
 
 
 
 
00a404f
a1de66d
 
 
 
 
 
 
00a404f
a1de66d
 
 
00a404f
a1de66d
 
00a404f
a1de66d
 
 
 
 
 
 
 
00a404f
a1de66d
 
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
import streamlit as st
import re

# Function to process each line of the chord sheet
def process_line(line):
    # Check if the line is a chord line (contains chord symbols)
    if re.search(r'\b[A-G][#b]?m?\b', line):
        # Replace chord symbols with image tags
        line = re.sub(r'\b([A-G][#b]?m?)\b', r"<img src='\1.png' style='height:20px;'>", line)
    return line

# Function to process the entire chord sheet
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)

# Streamlit app
def main():
    st.title('Chord Sheet Processor')

    # Text area for user to input the chord sheet
    chord_sheet_input = st.text_area("Enter your chord sheet here:", height=300)

    if st.button('Process Chord Sheet'):
        if chord_sheet_input:
            # Processing the chord sheet
            processed_sheet = process_chord_sheet(chord_sheet_input)
            # Displaying the processed chord sheet
            st.markdown(processed_sheet, unsafe_allow_html=True)
        else:
            st.error("Please input a chord sheet to process.")

if __name__ == '__main__':
    main()