Dynamic Versioning
API.audio allows you to personalize and localise your audio. Using personalisation variables, you can turn a single script into thousand of different versions of audio.
Let's look at an example of how to create several different speech files from a single script, in one go.
# Define audience parameters
import apiaudio
apiaudio.api_key ="API_KEY"
audience_params = [
{"band": "Nickelback", "city": "Berlin"},
{"band": "The Animals", "city": "Barcelona"},
{"band": "Coldplay", "city": "London"},
]
Now, let's create a script text and define
# CREATE script text and define audience parameters
text = """
Great news for all {{band}} fans!
They have just added two new tour dates to their previously sold-out concert in {{city}}.
Head over to buytickets.com to grab your tickets before they sell out!
"""
Now, let's create speech for every audience parameter in our list and master our audio
for audience in audience_params:
script = apiaudio.Script.create(
scriptText=text,
scriptName="concertad"
)
speech = apiaudio.Speech.create(
scriptId=script.get("scriptId"),
voice="sonia",
audience=audience
)
print(speech)
See complete example below:
Updated over 2 years ago