Some advanced script functionality
What can you do with script. What are projectNames, moduleNames and scriptNames for?
Let's imagine you create a few scripts. A natural problem that will emerge is "I have loads of scripts and I can't find them". Or if like some of us you have hundreds of files on your desktop, you won't be able to find anything.
We encountered this problem early, and so we invented the ability to specify script name, module name and project name.
The hierarchy is basically script live within modules and those live within projects.
Let's take a concrete example. Let's say I'm building a synthetic audio podcast for the "Daily Arrow". And the "Daily Arrow" has a finance website and a general news website.
Then I'd create something like.
script = apiaudio.Script.create(scriptText=text, scriptName="news",
projectName="daily parrot", moduleName="finance")
I can see all of my scripts with
scripts = apiaudio.Script.list()
Of course this can get unwieldy, and you might get confused.
However what if I want to see only the scripts with the projectName
of daily parrot
scripts = apiaudio.Script.list(projectName="daily parrot")
print(scripts)
You also might have noticed that if you write
print(script.get("scriptId"))
You'll get a unique number something like 4136164d-082a-4914-9279-ad4f0533b2cf
This unique id means you can reference the same script many times.
What can you do with this? Well you may want to experiment with different voices
r = apiaudio.Speech().create(
scriptId=script.get("scriptId"),
voice="olivia",
speed=105
)
print(r)
You can then listen to the audio at the url in the response. Let's say I don't like this accent - I might want to try another voice.
r = apiaudio.Speech().create(
scriptId=script.get("scriptId"),
voice="ryan",
speed=105
)
print(r)
You'll notice in this response that we changed the voice WITHOUT changing the scriptId.
Updated over 2 years ago