Multi-Voice Speech
API.audio enables you to create speech with multiple AI voices from several different providers for dynamic and personalised audio content. Choose from our catalogue of voices from all major providers. Mix and match these speakers in your script to create beautiful audio tracks.
Getting Started
In order to use multiple voices in your script text, you first need to create a script annotated by sections.
A script can be divided into script sections. A script section does not only help to organise and better manage your content but also makes it possible to make your content more dynamic by changing parameter settings within a script (such as: speakers, effects, speed, etc.)
A sample script with two sections can look something like this:
scriptText="""
<<sectionName::introduction>> Hi this is my ad
<<sectionName::main>> The main part is the most important
<<sectionName::cta>> And that's a wrap.
"""
After defining your script, you can move on to creating speech. To assign multiple speakers to each of your script sections you need to define sections
parameter in the speech call.
sections
is a dictionary (key, value pairs), where the key is a section name, and the value is another dictionary with the section configuration.
sections={
"introduction": {
"voice": "Aria",
"speed": 110,
},
"main": {
"voice": "Sonia",
"speed": 100
},
"cta": {
"voice": "Liam",
"speed": 100
}
}
End-to-End Example
Create a script, define multiple sections, assign different configuration parameters, master it with a sound design of your choice, and voilà! You have a fully produced beautiful audio track.
import apiaudio
apiaudio.api_key = "your_key"
# Let's create a script!
text = """
<<soundSegment::intro>>
<<sectionName::intro>>
Hey! Do you know we support multiple voices from different providers in the same script? My name is Sonia. I am from Microsoft!
<<soundSegment::main>>
<<sectionName::main>>
And my name is Austin! I am a Resemble provided voice. Try me out!
<<soundSegment::outro>>
<<sectionName::outro>>
Nice to meet you! I am Beth and I come from amazon! Try our voices out with your own script
"""
script = apiaudio.Script().create(scriptText=text, scriptName="multiple_speakers")
print(script)
# Create text to speech !
speech = apiaudio.Speech().create(
scriptId=script["scriptId"],
voice="Linda",
sections={
"intro": {"voice": "Sonia", "speed": 100},
"main": {"voice": "Austin", "speed": 90},
"outro": {"voice": "Beth", "speed": 100},
},
)
# Mastering creation
mastering = apiaudio.Mastering().create(
scriptId=script["scriptId"], soundTemplate="lofi"
)
file = apiaudio.Mastering().download(scriptId=script["scriptId"])
print(file)
Updated over 2 years ago