How to Create a Script

In this example, we'll create a simple script, and print out the metadata we get from the API response.

import audiostack
import os

#Code below is edited from the audiostack API quickstart guide
"""
Hello! Welcome to the audiostack python SDK. 
"""


BASE_URL = "http://v2.api.audio"
KEY = os.environ['AUDIOSTACK_API_KEY']
audiostack.api_base = BASE_URL
audiostack.api_key = KEY
text = """
  Hey how are you today?
"""

print(f"Creating your script...")
script = audiostack.Content.Script.create(scriptText=text)
print(script)

In your response you'll see something like

{"data": {"projectName": "untitled", "moduleName": "untitled", "scriptName": 
"untitled", "scriptId": "e50464d6-3996-4c9f-b801-d1eb6cb0cc6a", 
"scriptText": "<as:section name=\"default\">Hey how are you today?</as:section>", 
"metadata": "{}", "creationDate": "2024-05-10T14:21:46.052679", "lang": "so", "sections": 
[{"name": "default", "soundSegment": "", "contentType": "tts", "content": 
"Hey how are you today?", "placeholders": {}, "parent": "", "subSections": [], 
"uuid": "81d2feca-3eab-4c75-812a-fb077cd5a4df"}], "forceVIL": false}, 
"meta": {"version": "2.0.0", "requestId": "156c2334-7d2a-4e42-aea0-a3a75b4c3164", 
"creditsUsed": 0.1, "creditsRemaining": 500}, 
"message": "Script created", "warnings": [], "statusCode": 200}

You'll often want to retrieve scriptId and use that elsewhere in the platform!


What’s Next