Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,25 @@ import glob
|
|
8 |
st.set_page_config(layout="wide")
|
9 |
|
10 |
def process_line(line):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
if re.search(r'\b[A-G][#b]?m?\b', line):
|
12 |
line = re.sub(r'\b([A-G][#b]?m?)\b', r"<img src='\Em.png' style='height:20px;'>", line)
|
13 |
return line
|
|
|
8 |
st.set_page_config(layout="wide")
|
9 |
|
10 |
def process_line(line):
|
11 |
+
# Define a dictionary for chord-to-image mapping
|
12 |
+
chord_images = {
|
13 |
+
'Em': 'Em.png',
|
14 |
+
'D': 'D.png',
|
15 |
+
'C': 'C.png'
|
16 |
+
}
|
17 |
+
|
18 |
+
# Function to replace chord with image
|
19 |
+
def replace_chord(match):
|
20 |
+
chord = match.group(0)
|
21 |
+
return f"<img src='{chord_images.get(chord, 'default.png')}' style='height:20px;'>"
|
22 |
+
|
23 |
+
# Use regular expression to find and replace chords
|
24 |
+
pattern = r'\b(' + '|'.join(re.escape(chord) for chord in chord_images.keys()) + r')\b'
|
25 |
+
line = re.sub(pattern, replace_chord, line)
|
26 |
+
return line
|
27 |
+
|
28 |
+
|
29 |
+
def process_line_old(line):
|
30 |
if re.search(r'\b[A-G][#b]?m?\b', line):
|
31 |
line = re.sub(r'\b([A-G][#b]?m?)\b', r"<img src='\Em.png' style='height:20px;'>", line)
|
32 |
return line
|