@aiola/web-sdk-tts
Aiola Text-to-Speech JavaScript SDK
example code can be found here
Installation
npm install @aiola/web-sdk-tts
yarn add @aiola/web-sdk-tts
Usage
Node.js (CommonJS)
const AiolaTTSClient = require("@aiola/web-sdk-tts");
const ttsClient = new AiolaTTSClient({
baseUrl: "<BASE_URL>",
bearer: "<BEARER>",
});
Modern JavaScript (ES Modules)
import AiolaTTSClient from "@aiola/web-sdk-tts";
const ttsClient = new AiolaTTSClient({
baseUrl: "<BASE_URL>",
bearer: "<BEARER>",
});
Browser (Direct Usage)
<script type="importmap">
{
"imports": {
"@aiola/web-sdk-tts": "./node_modules/@aiola/web-sdk-tts/dist/bundle/index.js"
}
}
</script>
</script>
API Documentation
npm install @aiola/web-sdk-tts
import AiolaTTSClient from "@aiola/web-sdk-tts";
const ttsClient = new AiolaTTSClient({
baseUrl: "https://your-aiola-endpoint.com",
bearer: "your-auth-token",
});
const voices = ttsClient.getVoices();
const clientWithDefault = new AiolaTTSClient({
baseUrl: "https://your-aiola-endpoint.com",
bearer: "your-auth-token",
defaultVoice: voices.Default,
});
const audioBlob = await clientWithDefault.synthesizeSpeech(
"Hello, world!",
voices.Bella
);
const url = URL.createObjectURL(blob);
audioPlayer.src = url;
audioPlayer.style.display = "block";
audioPlayer.play();
const audioBlob2 = await clientWithDefault.synthesizeSpeech("Hello, world!");
const clientWithoutDefault = new AiolaTTSClient({
baseUrl: "https://your-aiola-endpoint.com",
bearer: "your-auth-token",
});
await clientWithoutDefault.synthesizeSpeech("Hello, world!");
const streamBlob = await clientWithDefault.streamSpeech(
"Hello, world!",
voices.Nicole
);
TTSConfig Interface
interface TTSConfig {
baseUrl: string;
bearer: string;
defaultVoice?: string;
}
Development
npm install
npm run build
npm run type-check
License
See LICENSE file for details.
Support
For any issues or questions regarding the aiOla TTS SDK, please contact us