Speech Resource

Speech allows you to do Text-To-Speech (TTS) with our API using all the voices available. Use it to create a speech audio file from your script.

Speech Methods

🚀 create()

Send a Text-To-Speech request to our Text-To-Speech service.

Parameters:

  • scriptId * Required (string) - The script ID

  • voice (string) - Voice name. See the list of available voices using Voice resource. Default voice is "Joanna".

  • speed (int) - Voice speed. Default speed is 100.

  • effect (string) - Put a funny effect in your voice. You can try the following ones: dark_father, 88b, 2r2d, chewie, volume_boost_low volume_boost_middle volume_boost_high (Volume boost allows you to adjust the volume of speech. NOTE! Volume boost effect only applies to speech creation and will be overwritten by the mastering process)

  • silence_padding (integer) - Add a silence padding to your speech tracks (in milliseconds). Default is 0 (no padding)

  • audience (list of dicts) - List of dicts containing the personalisation parameters as key-value pairs. This parameter depends on the number of parameters you used in your script resource. For instance, if in the script resource you have scriptText="Hello {{name}} {{lastname}}, welcome to {{location}}", the audience should be: [{"name": "Elon", "lastname": "Musk", "location": "Space"}]

  • sync (boolean) - Allow sync or async speech creation. Default is True. If sync=False, speech create call will return a success message when the speech creation is triggered. To retrieve the files, check Speech.retrieve() method.

  • sections (dictionary) is a dictionary (key-value pairs), where the key is a section name, and the value is another dictionary with the section configuration ( valid parameters are: voice, speed, effect, silence_padding). If a section is not found here, the section will automatically inherit the voice, speed, effect and silence_padding values you defined above (or the default ones if you don't provide them). See an example below with 2 sections and different configuration parameters being used.

sections={
        "firstsection": {
            "voice": "Matthew",
            "speed": 110,
            "silence_padding": 100,
            "effect": "dark_father"
        },
        "anothersection": {
            "voice": "en-GB-RyanNeural",
            "speed": 100
        }
    }
sections:{
        "firstsection": {
            "voice": "Matthew",
            "speed": 110,
            "silence_padding": 100,
            "effect": "dark_father"
        },
        "anothersection": {
            "voice": "en-GB-RyanNeural",
            "speed": 100
        }
    }

Simple Example

response = apiaudio.Speech.create(
    scriptId="id-1234",
    voice="Linda"
)
const speech = await apiaudio.Speech.create({ scriptId: script["scriptId"], voice: "Linda" });
console.log(speech);

Complete Example:

response = apiaudio.Speech.create(
    scriptId="id-1234",
    voice="Matthew",
    speed=100,
    effect="dark_father",
  	silence_padding= 1000,
    audience=[{"username": "Elon", "lastname": "Musk"}],
    sync=True
    sections={
        "firstsection": {
            "voice": "Matthew",
            "speed": 110,
            "silence_padding": 100,
            "effect": "dark_father"
        },
        "anothersection": {
            "voice": "en-GB-RyanNeural",
        }
    }
)
const speech = await apiaudio.Speech.create({
      scriptId: script["scriptId"],
      voice: "en-US-Standard-D",
      speed: 90,
      silence_padding: 0,
      sections: {
        question: {
          voice: "Amy",
          speed: 110,
          silence_padding: 1000,
        },
        answer: {
          voice: "en-GB-RyanNeural",
          speed: 100,
        },
      },
    });
    console.log(speech);

🔊retrieve()

Retrieve the speech file urls.

Parameters:

  • scriptId *Required (string) - The script ID you want to retrieve.

  • section (string) - The script section name for the first section. The default name for a script section is "default". NOTE: At the moment, Only scripts with 1 section are supported. If the scripts contain more than one section, only the first section can be retrieved.

  • parameters (dict) - Dict containing the personalisation parameters for the first section of the script. This parameter depends on the parameters you used in your script's resource section. If this parameter is used, section must be specified.

Example:

audio_files = apiaudio.Speech.retrieve(scriptId="id-1234")
await Speech.retrieve(scriptId, section?, parameters?)

🔊download()

Download the speech files in your preferred folder.

Parameters:

  • scriptId *Required (string) - The script ID you want to download

  • section (string) - The script section name for the first section. The default name for a script section is "default". NOTE: At the moment, Only scripts with 1 section are supported. If the scripts contain more than one section, only the first section can be retrieved.

  • parameters (dict) - Dict containing the personalisation parameters for the first section of the script. This parameter depends on the parameters you used in your script's resource section. If this parameter is used, section must be specified.

  • destination (string) - The folder destination path. Default is "." (current folder)

Example:

audio_files = apiaudio.Speech.download(scriptId="id-1234", destination=".")