Custom Sound Design Templates

In this guide we will look at how to upload a custom sound design template.

A sound template contains two distinct components, metadata and segments.

Metadata simply put is metadata detailing the style, genre, tags and description of the sound template.

Segments are the audio file components of a sound template object. A template can contain many sound segments, in our own library they usually have 3, intro, main, and outro. These names are only used as symbolic placeholders , you might wish to name yours differently.

Creating a template

To create a template we must first register a new template.

template = audiostack.Production.Sound.Template.create(templateName="epic1") 

🚧

Templates must be uniquely named. Use the following line of code to delete a template and all of its segments.

> 🚧 audiostack.Production.Sound.Template.delete(templateName="epic1")

uploading sound segments

Uploading a sound segment is a two step process. First we need to upload our sound segment to the media service, and then we make a second api call to register this media file as a sound segment. In the example below we upload our a file named epic_main.wav and this becomes our main soundSegment

media = audiostack.Content.Media.create(filePath="epic_main.wav")
template = audiostack.Production.Sound.Segment.create(templateName="epic1", mediaId=media.mediaId, soundSegmentName="main")

To upload another sound segment the above process should be repeated.

❗️

Only wav files are supported as sound segments

Please convert this content before uploading. This can be done locally with:
ffmpeg -i <file> -o <file.wav>

Testing

To test our sound template lets make an end-to-end production request.

script = audiostack.Content.Script.create(
    scriptText="""<as:section name="main" soundSegment="main">  Hello world! </as:section>"""
)

speech = audiostack.Speech.TTS.create(scriptItem=script)

mix = audiostack.Production.Mix.create(
    speechItem=speech,
    soundTemplate="epic1",
)

mix.download()

🚧

The soundSegment field in the script must match a valid soundSegment name

The following markup in the script <as:section name="main" soundSegment="main">will play the sound segment main from your supplied sound template. An error is throw in the Mix endpoint if your template does not have a named soundSegment