Spaces:
Runtime error
Runtime error
adding more songs and singers
Browse files
app.py
CHANGED
|
@@ -70,38 +70,90 @@ def flattenLines(lyrics):
|
|
| 70 |
return newValues
|
| 71 |
|
| 72 |
def getPayload(index):
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
|
| 107 |
|
|
@@ -112,7 +164,7 @@ def greet(index, lyrics):
|
|
| 112 |
print("Calling api with "+ lyrics)
|
| 113 |
|
| 114 |
lines = lyrics.split("\n")
|
| 115 |
-
newLines = flattenLines(list(map(separate_syllables, lines)))
|
| 116 |
|
| 117 |
payload = getPayload(index)
|
| 118 |
payload["lyrics"] = lines
|
|
@@ -136,6 +188,9 @@ def greet(index, lyrics):
|
|
| 136 |
print(response.text)
|
| 137 |
print(jobID)
|
| 138 |
jsonResp = response.json()
|
|
|
|
|
|
|
|
|
|
| 139 |
if('transformedAudioUrl' in jsonResp and jsonResp['transformedAudioUrl'] is not None):
|
| 140 |
return gr.make_waveform(download_file(jsonResp['transformedAudioUrl']))
|
| 141 |
#return download_file(jsonResp['urlVideoWithBackground'])
|
|
@@ -169,12 +224,20 @@ with gr.Blocks() as demo:
|
|
| 169 |
### Disclaimer
|
| 170 |
Each melody has specific requirements for the lyrics (number of notes per verse and duration of each note).
|
| 171 |
Use the examples provided to understand how they work and write valid lyrics to get best results
|
|
|
|
|
|
|
| 172 |
""")
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
with gr.Row():
|
| 175 |
with gr.Column():
|
| 176 |
with gr.Row():
|
| 177 |
-
dd = gr.Dropdown(choices=
|
| 178 |
lines = gr.Textbox(lines=10, placeholder="Write your lyrics here...", label="Lyrics")
|
| 179 |
|
| 180 |
with gr.Row():
|
|
@@ -203,7 +266,15 @@ with gr.Blocks() as demo:
|
|
| 203 |
> this is moving too fast
|
| 204 |
> I can help you be
|
| 205 |
> a better singer
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
""")
|
| 208 |
with gr.Column():
|
| 209 |
gr.Markdown("""
|
|
@@ -215,6 +286,27 @@ with gr.Blocks() as demo:
|
|
| 215 |
> Fa la la la la, la la la la
|
| 216 |
|
| 217 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
gr.Markdown("""
|
| 219 |
## Want to use this API for your project?
|
| 220 |
|
|
|
|
| 70 |
return newValues
|
| 71 |
|
| 72 |
def getPayload(index):
|
| 73 |
+
match index:
|
| 74 |
+
case 0:
|
| 75 |
+
return {
|
| 76 |
+
"voiceModel":"CFV_2",
|
| 77 |
+
"voiceModelStyle":"mezzo",
|
| 78 |
+
"language":"en",
|
| 79 |
+
"scoreFileRemotePath":"themes/DeckTheHalls/score/TTS_XMAS_DeckTheHalls_Melody_C_200bpm_4x4_ABCD.json",
|
| 80 |
+
"scoreDataFileRemotePath":"themes/DeckTheHalls/score/TTS_XMAS_DeckTheHalls_Score_Data_ABCD.json",
|
| 81 |
+
"dspFileRemotePath":"themes/DeckTheHalls/dsp/XML/TTS_XMAS_DeckTheHalls_DSP_C_200bpm_ABCD.xml",
|
| 82 |
+
"dspEffect":"",
|
| 83 |
+
"lyrics": [],
|
| 84 |
+
"backgroundSounds":False,
|
| 85 |
+
"artistName":"Cecilia",
|
| 86 |
+
"songName":"Deck The Halls",
|
| 87 |
+
"singerImageRemotePath":"singers/Singer-Cecilia-VideoImageBackground.png",
|
| 88 |
+
"backgroundImageRemotePath":"themes/DeckTheHalls/images/Song-DeckTheHalls-VideoImageBackground02.png"
|
| 89 |
+
}
|
| 90 |
+
case 1:
|
| 91 |
+
return {
|
| 92 |
+
"voiceModel":"CFV_2",
|
| 93 |
+
"voiceModelStyle":"mezzo",
|
| 94 |
+
"language":"en",
|
| 95 |
+
"scoreDataFileRemotePath": "themes/MoveYourBody/score/MoveYourBody_Score_Data_ABCD.json",
|
| 96 |
+
"scoreFileRemotePath": "themes/MoveYourBody/score/MoveYourBody_Melody_ABCD.json",
|
| 97 |
+
"singerImageRemotePath": "singers/Singer-Cecilia-VideoImageBackground.png",
|
| 98 |
+
"dspFileRemotePath": "themes/MoveYourBody/dsp/XML/MoveYourBody_DSP_ABCD.xml",
|
| 99 |
+
"dspEffect":"",
|
| 100 |
+
"lyrics": [],
|
| 101 |
+
"backgroundSounds":False,
|
| 102 |
+
"artistName":"Cecilia",
|
| 103 |
+
"songName":"Move Your Body",
|
| 104 |
+
"backgroundImageRemotePath":"themes/DeckTheHalls/images/Song-DeckTheHalls-VideoImageBackground02.png"
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
case 2:
|
| 108 |
+
return {
|
| 109 |
+
"voiceModel": "Randy_v3o",
|
| 110 |
+
"voiceModelStyle": "randy",
|
| 111 |
+
"language": "en",
|
| 112 |
+
"scoreFileRemotePath": "themes/DarkTrap/score/DarkTrap_Melody_ABCDEFGH.json", #"themes/DeckTheHalls/score/TTS_XMAS_DeckTheHalls_Melody_C_200bpm_4x4_ABCD.json",
|
| 113 |
+
"scoreDataFileRemotePath": "themes/DarkTrap/score/DarkTrap_Score_Data_ABCDEFGH.json", #"themes/DeckTheHalls/score/TTS_XMAS_DeckTheHalls_Score_Data_ABCD.json",
|
| 114 |
+
"dspFileRemotePath": "themes/DarkTrap/dsp/XML/DarkTrap_DSP_ABCDEFGH.xml", #"themes/DeckTheHalls/dsp/XML/TTS_XMAS_DeckTheHalls_DSP_C_200bpm_ABCD.xml",
|
| 115 |
+
"dspEffect": "",
|
| 116 |
+
"lyrics": [],
|
| 117 |
+
"backgroundSounds": False,
|
| 118 |
+
"artistName": "Jerry",
|
| 119 |
+
"songName": "Dark Trap", #"Deck The Halls",
|
| 120 |
+
"singerImageRemotePath": "singers/Singer-Jerry-VideoImageBackground.png",
|
| 121 |
+
"backgroundImageRemotePath": "themes/DeckTheHalls/images/Song-DeckTheHalls-VideoImageBackground01.png"
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
case 3:
|
| 125 |
+
return {
|
| 126 |
+
"artistName": "Jerry",
|
| 127 |
+
"backgroundImageRemotePath": "themes/HappyBirthday/images/Song-HappyBirthday-VideoImageBackground01.png",
|
| 128 |
+
"backgroundSounds": False,
|
| 129 |
+
"dspEffect": "",
|
| 130 |
+
"dspFileRemotePath": "themes/HappyBirthday/dsp/XML/HappyBirthday_DSP_ABCD.xml",
|
| 131 |
+
"language": "en",
|
| 132 |
+
"lyrics": [],
|
| 133 |
+
"scoreDataFileRemotePath": "themes/HappyBirthday/score/HappyBirthday_Score_Data_ABCD.json",
|
| 134 |
+
"scoreFileRemotePath": "themes/HappyBirthday/score/HappyBirthday_Melody_ABCD.json",
|
| 135 |
+
"singerImageRemotePath": "singers/Singer-Jerry-VideoImageBackground.png",
|
| 136 |
+
"songName": "Happy Birthday",
|
| 137 |
+
"voiceModel": "CFV_2",
|
| 138 |
+
"voiceModelStyle": "baritone"
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
case 4:
|
| 142 |
+
return {
|
| 143 |
+
"voiceModel": "Randy_v3o",
|
| 144 |
+
"voiceModelStyle": "randy",
|
| 145 |
+
"language": "en",
|
| 146 |
+
"scoreFileRemotePath": "themes/Levitate/score/Levitate_Melody_ABCD.json", #"themes/DeckTheHalls/score/TTS_XMAS_DeckTheHalls_Melody_C_200bpm_4x4_ABCD.json",
|
| 147 |
+
"scoreDataFileRemotePath": "themes/Levitate/score/Levitate_Score_Data_ABCD.json", #"themes/DeckTheHalls/score/TTS_XMAS_DeckTheHalls_Score_Data_ABCD.json",
|
| 148 |
+
"dspFileRemotePath": "themes/Levitate/dsp/XML/Levitate_DSP_ABCD.xml", #"themes/DeckTheHalls/dsp/XML/TTS_XMAS_DeckTheHalls_DSP_C_200bpm_ABCD.xml",
|
| 149 |
+
"dspEffect": "",
|
| 150 |
+
"lyrics": [],
|
| 151 |
+
"backgroundSounds": False,
|
| 152 |
+
"artistName": "Jerry",
|
| 153 |
+
"songName": "Levitate", #"Deck The Halls",
|
| 154 |
+
"singerImageRemotePath": "singers/Singer-Ed-VideoImageBackground.png",
|
| 155 |
+
"backgroundImageRemotePath": "themes/Levitate/images/Song-Levitate-VideoImageBackground02.png"
|
| 156 |
+
}
|
| 157 |
|
| 158 |
|
| 159 |
|
|
|
|
| 164 |
print("Calling api with "+ lyrics)
|
| 165 |
|
| 166 |
lines = lyrics.split("\n")
|
| 167 |
+
#newLines = flattenLines(list(map(separate_syllables, lines)))
|
| 168 |
|
| 169 |
payload = getPayload(index)
|
| 170 |
payload["lyrics"] = lines
|
|
|
|
| 188 |
print(response.text)
|
| 189 |
print(jobID)
|
| 190 |
jsonResp = response.json()
|
| 191 |
+
if(jsonResp['status'] == 'failed'):
|
| 192 |
+
return ""
|
| 193 |
+
|
| 194 |
if('transformedAudioUrl' in jsonResp and jsonResp['transformedAudioUrl'] is not None):
|
| 195 |
return gr.make_waveform(download_file(jsonResp['transformedAudioUrl']))
|
| 196 |
#return download_file(jsonResp['urlVideoWithBackground'])
|
|
|
|
| 224 |
### Disclaimer
|
| 225 |
Each melody has specific requirements for the lyrics (number of notes per verse and duration of each note).
|
| 226 |
Use the examples provided to understand how they work and write valid lyrics to get best results
|
| 227 |
+
|
| 228 |
+
Also, the length of the song is fixed, if you go over the line numbers the extra lyrics will be ignored.
|
| 229 |
""")
|
| 230 |
|
| 231 |
+
music_options = ["Deck the Halls by Cecilia",
|
| 232 |
+
"Move your Body by Cecilia",
|
| 233 |
+
"Dark Trap by Jerry",
|
| 234 |
+
"Happy Birthday by Jerry",
|
| 235 |
+
"Levitate by Ed"]
|
| 236 |
+
|
| 237 |
with gr.Row():
|
| 238 |
with gr.Column():
|
| 239 |
with gr.Row():
|
| 240 |
+
dd = gr.Dropdown(choices=music_options, type="index", label="Select the melody...")
|
| 241 |
lines = gr.Textbox(lines=10, placeholder="Write your lyrics here...", label="Lyrics")
|
| 242 |
|
| 243 |
with gr.Row():
|
|
|
|
| 266 |
> this is moving too fast
|
| 267 |
> I can help you be
|
| 268 |
> a better singer
|
| 269 |
+
""")
|
| 270 |
+
with gr.Column():
|
| 271 |
+
gr.Markdown("""
|
| 272 |
+
### Happy Birthday by Jerry
|
| 273 |
|
| 274 |
+
> happy birthday to you
|
| 275 |
+
> happy birthday to you!
|
| 276 |
+
> happy birthday dear Laura
|
| 277 |
+
> happy birthday to you!
|
| 278 |
""")
|
| 279 |
with gr.Column():
|
| 280 |
gr.Markdown("""
|
|
|
|
| 286 |
> Fa la la la la, la la la la
|
| 287 |
|
| 288 |
""")
|
| 289 |
+
with gr.Column():
|
| 290 |
+
gr.Markdown("""
|
| 291 |
+
### Levitate by Ed
|
| 292 |
+
|
| 293 |
+
> this is just a test
|
| 294 |
+
> don’t worry about what I say
|
| 295 |
+
> the lyrics want to go crazy
|
| 296 |
+
> when pushed too hard
|
| 297 |
+
""")
|
| 298 |
+
with gr.Column():
|
| 299 |
+
gr.Markdown("""
|
| 300 |
+
### Move Your Body by Cecilia
|
| 301 |
+
|
| 302 |
+
> this is just a test
|
| 303 |
+
> don’t worry now
|
| 304 |
+
> the lyrics will come the less you think about them
|
| 305 |
+
> just feel the melody
|
| 306 |
+
""")
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
|
| 310 |
gr.Markdown("""
|
| 311 |
## Want to use this API for your project?
|
| 312 |
|