Script Syntax
To write a Script, we provide our own set of ssml
tags for instructing how tts speech is generated, and how these speech files are later combined with Sound Templates, media files, and sound effects. All of our tags are prefixed with as:
syntax (short for AudioStack).
Sections
All scripts should start and end with a <as:section>
<as:section name="hello">
Hello world, this section is named hello.
</as:section>
Scripts not created without a section tag will have one generated automatically. A script can contain many sections, but sections cannot be nested. See as:sub
for adding sub-sections.
To combine a speech file with a sound design, apply the soundsegment
attribute to the as:section
tag.
<as:section name="intro" soundsegment="intro">
This is the first section and will be combined with the intro music.
</as:section>
<as:section name="main" soundsegment="main">
This is the second section and will be combined with the main music. The section name and soundsegment don't have to have the same name.
</as:section>
Sub-sections
To insert sub-sections you need to use the <as:sub>
tag. By default all sub-sections will be rendered with the same voice, but this can be configured in the speech call. However all the tts content with the section will be combined with the supplied sound segment.
Sub-sections cannot be nested.
<as:section name="intro" soundsegment="intro">
<as:sub name="introa"> This is sub-section 1 </as:sub>
<as:sub name="introb"> This is sub-section 2 </as:sub>
</as:section>
Sound Effects & Media Files
To create awesome audio content you can also insert sound effects and media files. Conceptually these work the same, fx
are sound effects that we have curated for you, and media files can be user-uploaded. The tags for these are very similar.
<as:section name="intro" soundsegment="intro">
Hello and welcome to my awesome audio advert
<as:fx name="bang" id="fx1"/>
I have also uploaded my companies sound branding which will now play.
<as:media name="branding1" id="branding"/>
</as:section>
Use the name
if you wish to use a named asset. Use the id
tag if you wish to swap the content in a future Mastering request without recreating the script. Note that either name
or id
must be supplied.
Placeholder
This parameter can be used to customise or 'fill in' variable words/text during the TTS creation stage. To produce variants of a single script, just use the as:placeholder
tag to insert content during a speech creation call.
<as:section name="intro" soundsegment="intro">
hello enjoy a coffee with <as:placeholder id="username">name</as:placeholder>
</as:section>
The content between the placeholder tag is the default content that will be used, the id
parameter is used to replace this content during the speech call. For example, setting username="sam".
Code Example
For reference these are all the audiostack specific ssml
tags:
<as:section name="main" soundSegment="main"> hello </as:section>
<as:sub name="main"> hello </as:sub>
<as:fx name="riser" id="fx1" />
<as:media name="soundbranding.wav" id="media1" />
<as:placeholder id="username"> fallback </as:placeholder>
<as:preserve> This text will not be corrected by voice intelligence service </as:preserve>
Muting a Section
If you want to mute a section (i.e. not have any sound design playing in the section), simply remove the soundsegment
from the section tag (<as:section name="main">
).
scriptText = """
<as:section name="intro" soundsegment="intro">
hello this is the new script syntax
</as:section>
<as:section name="main">
This uses regular H T M L syntax and replaces our old script formatting
</as:section>
<as:section name="outro" soundsegment="outro">
This massively improves usability, aids with learnability and should improve adoption
</as:section>"""
Updated 10 months ago