Update app.py
Browse files
app.py
CHANGED
|
@@ -144,25 +144,29 @@ def get_supported_languages_display() -> str:
|
|
| 144 |
"""
|
| 145 |
|
| 146 |
def format_for_singing(lyrics: str) -> str:
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
-
|
| 160 |
-
hmm-hmm-hmm ♪
|
| 161 |
|
| 162 |
-
|
| 163 |
|
| 164 |
-
{lyrics}
|
| 165 |
-
"""
|
| 166 |
|
| 167 |
DEVICE = "cpu"
|
| 168 |
MODEL = None
|
|
|
|
| 144 |
"""
|
| 145 |
|
| 146 |
def format_for_singing(lyrics: str) -> str:
|
| 147 |
+
"""
|
| 148 |
+
Encode melody directly into text for Chatterbox.
|
| 149 |
+
NO instructions. ONLY singable text.
|
| 150 |
+
"""
|
| 151 |
+
lines = []
|
| 152 |
+
for line in lyrics.splitlines():
|
| 153 |
+
line = line.strip()
|
| 154 |
+
if not line:
|
| 155 |
+
continue
|
| 156 |
+
|
| 157 |
+
# simple vowel stretching
|
| 158 |
+
line = (
|
| 159 |
+
line.replace("a", "aa")
|
| 160 |
+
.replace("e", "ee")
|
| 161 |
+
.replace("i", "ii")
|
| 162 |
+
.replace("o", "oo")
|
| 163 |
+
.replace("u", "uu")
|
| 164 |
+
)
|
| 165 |
|
| 166 |
+
lines.append(f"{line} ♪ ...")
|
|
|
|
| 167 |
|
| 168 |
+
return "\n".join(lines)
|
| 169 |
|
|
|
|
|
|
|
| 170 |
|
| 171 |
DEVICE = "cpu"
|
| 172 |
MODEL = None
|