Script Resource

The Script resource/class allows you to create, retrieve and list scripts. Learn more about scripts here.

Script Methods

✍️create()

Create a new script.

Parameters:

  • scriptText * Required (string) - Text for your script. A script can contain multiple sections and SSML tags. Learn more about scriptText details here

  • projectName (string) - The name of your project. Default value is "default"

  • moduleName (string) - The name of your module. Default value is "default"

  • scriptName (string) - The name of your script. Default value is "default"

  • scriptId (string) - Custom identifier for your script. If scriptId parameter is used, then projectName, moduleName and scriptName are required parameters.

Example:

script = apiaudio.Script.create(
    scriptText="<<sectionName::hello>> Hello {{username|buddy}} <<sectionName::goodbye>> Good bye from {{location|barcelona}}",
    projectName="myProject",
    moduleName="myModule",
    scriptName="myScript",
    scriptId="id-1234"
    )
let script = await Script.create({ scriptText: "Hello world" });
console.log(script);

📘

Need Inspiration?

Have a look at some script examples here

⬇️ retrieve()

Retrieve a script by id.

Parameters:

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

Example:

script = apiaudio.Script.retrieve(scriptId="id-1234")
script = await Script.retrieve(script["scriptId"]);
console.log(script);

⬇️ list()

List all scripts available in your organization.

Parameters:

  • No parameters required.

Example:

scripts = apiaudio.Script.list()
let scripts = await Script.list();
console.log(scripts);

⬇️ get_random_text()

Retrieve random text from a list of categories.

Parameters:

  • category (string) - The category from which the random text is retrieved. If no category is specified, the function defaults to "FunFact"

Example:

text = apiaudio.Script.get_random_text(category="BibleVerse")
await Script.getRandomText(category?: string)

Categories currently available: "BibleVerse", "FunFact", "InspirationalQuote", "Joke", "MovieSynopsis", "Poem", "PhilosophicalQuestion", "Recipe", "TriviaQuestion".


Did this page help you?