@aflr/audiostack
v1.1.24
Published
Audiostack Javascript SDK
Downloads
2,157
Readme
📝 Table of Contents
🧐 About
This repository is actively maintained by AudioStack. For examples, recipes and api reference see the AudioStack docs. Feel free to get in touch with any questions or feedback!
🧑💻 Maintainers
- https://github.com/timcoggins
📝 License
This project is licensed under the MIT License
📖 Changelog
You can view here our updated Changelog.
🏁 Getting Started
Installation
To install the SDK into your project, run the following command:
npm install @aflr/audiostack
# or
yarn install @aflr/audiostack
Authentication
This library needs to be configured with your account's api-key which is available in Audiostack Platform.
Configuration
Once you have your api-key, you can configure a new instance of Audiostack by using:
// CommonJS Syntax
const { Audiostack } = require("@aflr/audiostack");
// Create a new instance of Audiostack
const AS = new Audiostack("your_api_key");
You may also use the ES6 syntax:
// ES6 Module Syntax
import { Audiostack } from '@aflr/audiostack';
// Create a new instance of Audiostack
const AS = new Audiostack("your_api_key");
You can now use the Audiostack instance to access the API.
🚀 Hello World
Try it out on StackBlitz: https://stackblitz.com/edit/node-rwvl9n?file=example.js
In a new directory, run the following command to initalize a new project with NPM:
npm init -y
Install the SDK:
npm install @aflr/audiostack
Create a new file called example.ts
and add the following code with your api key:
// Import the library
const { Audiostack } = require("@aflr/audiostack");
// Provide your api key from the Audiostack Console
const apiKey = "your_api_key";
/**
* This example demonstrates how to produce and download a file using the Audiostack API.
*/
const example = async () => {
// Create a new instance of Audiostack
const AS = new Audiostack(apiKey);
// Create a script asset with our hello text
const script = await AS.Content.Script.create({
scriptText: "<as:section soundSegment=main>Hello from Audiostack. This is a test script. I hope you enjoy it.</as:section>",
});
// Create a speech asset using our script and the voice "sara"
const tts = await AS.Speech.Tts.create({
scriptId: script.scriptId,
voice: "sara",
});
// Create a mix with our speech asset and add the sound template "3am"
const mix = await AS.Production.Mix.create({
speechId: tts.speechId,
soundTemplate: "funky_summer",
});
// Encode the file to high quality mp3
const encode = await AS.Delivery.Encoder.encodeMix({
productionId: mix.productionId,
preset: "mp3_high",
});
// Download the file to the project directory
const path = await encode.download();
// Print the path to the file
console.log(`File downloaded to: ${path}`);
};
// Run the example
example();
To run the example, run the following command:
node example.js
Reference - Currently Available:
const AS = new AudioStack(apiKey, {options})
Content
Script
AS.Content.Script.create()
AS.Content.Script.get()
AS.Content.Script.update()
AS.Content.Script.list()
AS.Content.Script.listProjects()
AS.Content.Script.listModules()
AS.Content.Script.generateAdvert()
AS.Content.Script.editAdvert()
Recommend
AS.Content.Recommend.recommendBestMatch()
AS.Content.Recommend.recommendMood()
AS.Content.Recommend.recommendTone()
ScriptItem
Item.update()
Item.delete()
AdItem
Item.getScriptItem()
Item.delete()
File
AS.Content.File.createFolder()
AS.Content.File.getFolder()
AS.Content.File.deleteFolder()
AS.Content.File.createFile()
AS.Content.File.createAndUploadFile()
AS.Content.File.getFile()
AS.Content.File.editFile()
AS.Content.File.deleteFile()
AS.Content.File.search()
FolderItem
Item.createFile()
Item.createAndUploadFile()
Item.createFolder()
Item.update()
Item.delete()
FileItem
Item.update()
Item.edit()
Item.download()
FileUploadItem
Item.upload()
Media (deprecated)
AS.Content.Media.create()
AS.Content.Media.createUploadUrl()
AS.Content.Media.get()
AS.Content.Media.delete()
AS.Content.Media.list()
MediaItem (deprecated)
Item.delete()
Item.download()
Speech
Voice
AS.Speech.Voice.list()
AS.Speech.Voice.getVoiceData()
AS.Speech.Voice.getParameters()
AS.Speech.Voice.select()
Tts
AS.Speech.Tts.create()
AS.Speech.Tts.createSection()
AS.Speech.Tts.fastPreview()
AS.Speech.Tts.get()
AS.Speech.Tts.delete()
AS.Speech.Tts.list()
AS.Speech.Tts.reduceLength()
AS.Speech.Tts.removeSilence()
AS.Speech.Tts.annotate()
TtsItem
Item.download()
Item.delete()
Predict
AS.Speech.Predict.listVoices()
AS.Speech.Predict.predictLength()
Diction
AS.Speech.Diction.list()
AS.Speech.Diction.listCustom()
AS.Speech.Diction.listCustomWords()
AS.Speech.Diction.createWord()
AS.Speech.Diction.deleteWord()
VoiceClone
AS.Speech.VoiceClone.createInstantClone()
Production
Mix
AS.Production.Mix.create()
AS.Production.Mix.validate()
AS.Production.Mix.get()
AS.Production.Mix.delete()
AS.Production.Mix.list()
AS.Production.Mix.listPresets()
MixItem
Item.download()
Item.delete()
Sound
AS.Production.Sound.list()
AS.Production.Sound.get()
AS.Production.Sound.select()
AS.Production.Sound.create()
AS.Production.Sound.delete()
AS.Production.Sound.addSoundSegment()
Suite
AS.Production.Suite.evaluate()
AS.Production.Suite.denoise()
AS.Production.Suite.seperate()
AS.Production.Suite.transcribe()
AS.Production.Suite.trimSilence()
Delivery
Encoder
AS.Delivery.Encoder.encodeMix()
AS.Delivery.EncoderlistPresets()
EncoderItem
Item.download()