Multilingual Vocals
Generate rap songs about any topic with lyrics in Spanish, German, Dutch, and more.
In this guide we’ll show you how to build a song generator workflow in Spanish using the Uberduck API. We’ll use the Prompt Builder to create and test a prompt that generates Spanish-language lyrics, and the rap song generation API endpoint to turn these lyrics into a full song.
Create the prompt for Spanish lyrics with Prompt Builder
Let’s use the Uberduck Prompt Builder and OpenAI’s GPT3.5 to generate lyrics in Spanish.
Check out this video for a full Prompt Builder walk-through.
In the Prompt Builder, create a prompt with this text:
“Generate {{nLines}} of rap lyrics in Spanish. Use ONLY the Spanish language - do not use ANY English. Do not include any text except for the lyrics. Do not label the verses or the chorus. Please make the rap song about {{topic}}.”
Deploy the prompt and use it via API
For this part, you’ll need an Uberduck API key and API secret. You can create a key and secret from the settings page.
From the Prompt Builder, click the Deploy button to create a Deployment from the
prompt. This will create the deployment and navigate to the deployment page,
where you can see a sample curl
command invoking the prompt via API.
Let’s make that same HTTP request from Python code:
import os
import requests
api_key = os.environ.get("UBERDUCK_API_KEY")
api_secret = os.environ.get("UBERDUCK_API_SECRET")
response = requests.post(
"https://api.uberduck.ai/templates/deployments/spanish-rapping/generate",
json={
"variables": {
"nLines": "16",
"topic": "Doing a software demo",
}
},
auth=(api_key, api_secret),
)
lyrics = response.json()["choices"][0]["message"]["content"].split("\n")
# Remove empty lines that GPT3.5 inserts between stanzas.
lyrics = [l for l in lyrics if len(l) > 0]
Note that topic
is passed to the API as a variable, so it could be
parameterized by a web frontend that accepts a text input from a user.
Generate Spanish vocals
Now we can generate a full song using the song generator endpoint.
voice_uuid = "4d5acf49-04c7-45d2-a283-8e0b9868f2bc"
backing_track_uuid = "eb3217e5-1097-4342-a67c-adf505ce0723"
response = requests.post(
"https://api.uberduck.ai/tts/freestyle",
json={
"backing_track": backing_track_uuid,
"voicemodel_uuid": voice_uuid,
# NOTE: lyrics accepts a list of lists, where each inner list is a
# single verse.
"lyrics": [lyrics],
},
auth=(api_key, api_secret)
)
# Something like 'https://uberduck-audio-outputs.s3-us-west-2.amazonaws.com/457631c1-58c4-4621-aaa3-8be376b6ce1a/audio.wav'
response.json()["mix_url"]
And that’s it! Your output should sound something like this: