Getting Started with the API

Fundamentally we built our API to allow it to be easier for developers to create beautiful audio.

Audio consists of content management (or a script), using speech (which we use text-to-speech technology for) and adding sound.

Let us use one of our helper functions to get started super quickly. Then we'll reproduce this helper function with lower-level abstractions. We find this is a good way to learn.

We're going to use Orchestrator a helper function and we'll pick the voice - Liam. You can see more in our Voices Library. For our sound design (or soundTemplate) we picked worksinprogress. You can see more in our Sounds Library

The mp3 file will be automatically downloaded and will have a programmatically generated name.

We will use python for simplicity in this guide.

import apiaudio 
import os
apiaudio.api_key = os.environ['APIKEY']
audio_creation = apiaudio.Orchestrator.create_audio(scriptText="Hi nerds, wouldn't it be cool to build an audio message in 5 lines of code", voice="Liam", soundTemplate="workinprogress")

print(audio_creation)

👍

Try out other voices or sounds

For extra-credit and to learn faster look at our voices page and try a different voice from the one we selected!

Alternatively you may want to change the sounds in the background - you can see our selection here

Script (Content Management)

First thing is to create the text. We'll keep this super simple - although it can get quite complicated.

scriptText="Hi nerds, wouldn't it be cool to build an audio message in 5 lines of code"

script = apiaudio.Script.create(scriptText=text, scriptName="myfirstscript")
print(script.get("scriptId"))

You'll see in your response a scriptId this is a unique id which identifies that script. You never need to create that script again.
It will look something like 9a0904f8-caba-4e3c-b495-3ba0e8962082

Speech

#Turn your text into speech
r = apiaudio.Speech().create(
    scriptId=script.get("scriptId"),
   voice="liam",
    speed=105
)

Production

Production is about picking the right sound design. A sound design can be thought of as background sounds that you add or a soundscape that you add. You'll often need to experiment quite a lot with these to get the right one.

r = apiaudio.Mastering().create(
     scriptId=script.get("scriptId"),
     soundTemplate="workinprogress"
)
file = apiaudio.Mastering.download(scriptId=script.get("scriptId"))

So that's it you've created two audio files - one the simple way and one the more low-level way! Well done.