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 = """
<<soundSegment::intro>><<sectionName::intro>>
Great news for all {{band}} fans!
<<soundSegment::main>><<sectionName::main>>
They have just added two new tour dates to their previously sold-out concert in {{city}}.
<<soundSegment::outro>><<sectionName::outro>>
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
    )

    mastering = apiaudio.Mastering.create(
        scriptId=script.get("scriptId"),
        soundTemplate="jakarta",
        audience=audience
    )

    print(mastering)

See complete example below:


Did this page help you?