Spaces:
Sleeping
Sleeping
Yongkang ZOU
commited on
Commit
·
f388e55
1
Parent(s):
319a417
update verovio iframe
Browse files
app.py
CHANGED
|
@@ -51,22 +51,21 @@ def wav_to_midi_and_musicxml(wav_path: str, timestamp: str) -> Path:
|
|
| 51 |
return musicxml_path
|
| 52 |
|
| 53 |
def build_verovio_iframe(musicxml_path: Path) -> str:
|
| 54 |
-
"""
|
| 55 |
-
将 MusicXML 文件复制到 static 目录,并生成 Verovio 的 iframe HTML
|
| 56 |
-
"""
|
| 57 |
static_dir = Path("static")
|
|
|
|
| 58 |
target = static_dir / musicxml_path.name
|
| 59 |
shutil.copy(musicxml_path, target)
|
| 60 |
|
| 61 |
return f"""
|
| 62 |
<iframe
|
| 63 |
-
src="
|
| 64 |
width="100%"
|
| 65 |
height="500px"
|
| 66 |
style="border: none;"
|
| 67 |
></iframe>
|
| 68 |
"""
|
| 69 |
|
|
|
|
| 70 |
def generate_music_and_score(melody_file, prompt):
|
| 71 |
if not MUSICGEN_API_URL:
|
| 72 |
return None, "❌ 未配置 API URL,请检查 .env 文件"
|
|
|
|
| 51 |
return musicxml_path
|
| 52 |
|
| 53 |
def build_verovio_iframe(musicxml_path: Path) -> str:
|
|
|
|
|
|
|
|
|
|
| 54 |
static_dir = Path("static")
|
| 55 |
+
static_dir.mkdir(exist_ok=True)
|
| 56 |
target = static_dir / musicxml_path.name
|
| 57 |
shutil.copy(musicxml_path, target)
|
| 58 |
|
| 59 |
return f"""
|
| 60 |
<iframe
|
| 61 |
+
src="/verovio.html?load=static/{target.name}"
|
| 62 |
width="100%"
|
| 63 |
height="500px"
|
| 64 |
style="border: none;"
|
| 65 |
></iframe>
|
| 66 |
"""
|
| 67 |
|
| 68 |
+
|
| 69 |
def generate_music_and_score(melody_file, prompt):
|
| 70 |
if not MUSICGEN_API_URL:
|
| 71 |
return None, "❌ 未配置 API URL,请检查 .env 文件"
|