Spaces:
Runtime error
Runtime error
hf-lin
commited on
Commit
•
39d0b5a
1
Parent(s):
bbfa0a9
upload musescore
Browse files- .gitattributes +2 -0
- MuseScore-4.1.1.232071203-x86_64.AppImage +3 -0
- app.py +18 -24
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.psd filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.AppImage filter=lfs diff=lfs merge=lfs -text
|
MuseScore-4.1.1.232071203-x86_64.AppImage
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8658d29db937fe07d76b595d28a0d89b18b85b9e66040fc2b51b4714d36304cf
|
3 |
+
size 169133248
|
app.py
CHANGED
@@ -3,31 +3,24 @@ import os
|
|
3 |
import re
|
4 |
import subprocess
|
5 |
import time
|
6 |
-
from symusic import Score, Synthesizer
|
7 |
import torchaudio
|
8 |
import torch
|
9 |
-
import music21
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
score = music21.converter.parseData(musicxml_string)
|
20 |
-
|
21 |
-
# Convert MusicXML to SVG
|
22 |
-
svg_string = score.write('musicxml.png', fmt='musicxml', subformats=['svg'])
|
23 |
-
|
24 |
-
# Write SVG to file
|
25 |
-
with open(output_svg_path, 'wb') as f:
|
26 |
-
f.write(svg_string)
|
27 |
-
return output_svg_path
|
28 |
-
|
29 |
-
|
30 |
-
def parse_abc_notation(text="", conversation_id='1'):
|
31 |
os.makedirs(f"tmp/{conversation_id}", exist_ok=True)
|
32 |
ts = time.time()
|
33 |
abc_pattern = r'(X:\d+\n(?:[^\n]*\n)+)'
|
@@ -42,9 +35,9 @@ def parse_abc_notation(text="", conversation_id='1'):
|
|
42 |
|
43 |
# Convert abc notation to SVG
|
44 |
tmp_midi = f'tmp/{conversation_id}/{ts}.mid'
|
45 |
-
|
46 |
svg_file = f'tmp/{conversation_id}/{ts}.svg'
|
47 |
-
|
48 |
return svg_file, wav_file
|
49 |
else:
|
50 |
return None, None
|
@@ -55,8 +48,9 @@ if __name__ == "__main__":
|
|
55 |
gradio_app = gr.Interface(
|
56 |
parse_abc_notation,
|
57 |
inputs=["text"],
|
58 |
-
outputs=[gr.Image(label="
|
59 |
-
title="
|
|
|
60 |
)
|
61 |
|
62 |
gradio_app.launch()
|
|
|
3 |
import re
|
4 |
import subprocess
|
5 |
import time
|
6 |
+
from symusic import Score, Synthesizer
|
7 |
import torchaudio
|
8 |
import torch
|
|
|
9 |
|
10 |
+
# for rendering abc notation
|
11 |
+
os.environ['QT_QPA_PLATFORM']='offscreen'
|
12 |
+
subprocess.run(["chmod", "+x", "MuseScore-4.1.1.232071203-x86_64.AppImage"])
|
13 |
|
14 |
+
default_abc = """
|
15 |
+
X:1
|
16 |
+
L:1/8
|
17 |
+
M:2/4
|
18 |
+
K:G
|
19 |
+
|:"G" G>A Bc | dB dB |"C" ce ce |"D7" dB A2 |"G" G>A Bc | dB dB |"Am" cA"D7" FA |"G" AG G2 ::
|
20 |
+
"Em" g2"D" f>e | de Bd |"C" ce ce |"D7" dB A2 |"G" g2"D" f>e | de Bd |"Am" cA"D7" FA |"G" AG G2 :|
|
21 |
+
"""
|
22 |
|
23 |
+
def parse_abc_notation(text='', conversation_id='debug'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
os.makedirs(f"tmp/{conversation_id}", exist_ok=True)
|
25 |
ts = time.time()
|
26 |
abc_pattern = r'(X:\d+\n(?:[^\n]*\n)+)'
|
|
|
35 |
|
36 |
# Convert abc notation to SVG
|
37 |
tmp_midi = f'tmp/{conversation_id}/{ts}.mid'
|
38 |
+
s.dump_midi(tmp_midi)
|
39 |
svg_file = f'tmp/{conversation_id}/{ts}.svg'
|
40 |
+
subprocess.run(["./MuseScore-4.1.1.232071203-x86_64.AppImage", "-f", "-o", svg_file, tmp_midi])
|
41 |
return svg_file, wav_file
|
42 |
else:
|
43 |
return None, None
|
|
|
48 |
gradio_app = gr.Interface(
|
49 |
parse_abc_notation,
|
50 |
inputs=["text"],
|
51 |
+
outputs=[gr.Image(label="svg"), gr.Audio(label="audio")],
|
52 |
+
title="ABC notation parse",
|
53 |
+
examples=[default_abc]
|
54 |
)
|
55 |
|
56 |
gradio_app.launch()
|