
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
@aiola/sdk
Advanced tools
The official JavaScript/TypeScript SDK for the aiOla API, work seamlessly in both Node.js and browser environments.
npm install @aiola/sdk
# or
yarn add @aiola/sdk
The aiOla SDK uses a two-step authentication process:
This approach provides better security and proper session management.
import { AiolaClient } from '@aiola/sdk';
const { accessToken, sessionId } = await AiolaClient.grantToken({
apiKey: 'your-api-key'
});
const client = new AiolaClient({
accessToken: accessToken
});
import { AiolaClient } from '@aiola/sdk';
import fs from 'fs';
async function example() {
try {
// Step 1: Generate access token
const { accessToken } = await AiolaClient.grantToken({
apiKey: process.env.AIOLA_API_KEY!
});
// Step 2: Create client
const client = new AiolaClient({
accessToken: accessToken
});
// Step 3: Use client for API calls
const audioFile = fs.createReadStream('./audio.wav');
const transcript = await client.stt.transcribeFile({
file: audioFile,
language: 'en'
});
console.log('Transcript:', transcript);
} catch (error) {
console.error('Error:', error);
}
}
example();
The SDK automatically handles common scenarios like concurrency limits:
try {
const { accessToken } = await AiolaClient.grantToken({
apiKey: 'your-api-key'
});
} catch (error) {
if (error.code === 'MAX_CONCURRENCY_REACHED') {
console.log('Concurrency limit reached. Please wait for existing sessions to expire.');
}
}
Close Session on Server:
// Terminates the session on the server
await AiolaClient.closeSession(accessToken, {
apiKey: 'your-api-key'
});
const { accessToken } = await AiolaClient.grantToken({
apiKey: 'your-api-key',
authBaseUrl: 'https://mycompany.auth.aiola.ai',
});
const client = new AiolaClient({
accessToken: accessToken,
baseUrl: 'https://mycompany.api.aiola.ai',
});
import { AiolaClient } from '@aiola/sdk';
import fs from 'fs';
async function transcribeFile() {
try {
// Step 1: Generate access token
const { accessToken } = await AiolaClient.grantToken({
apiKey: process.env.AIOLA_API_KEY!
});
// Step 2: Create client
const client = new AiolaClient({
accessToken: accessToken
});
// Step 3: Transcribe file
const file = fs.createReadStream('path/to/your/audio.wav');
const transcript = await client.stt.transcribeFile({
file: file,
language: "en"
});
console.log(transcript);
} catch (error) {
console.error('Error transcribing file:', error);
}
}
transcribeFile();
import { AiolaClient } from '@aiola/sdk';
// Stream audio in real-time for live transcription
async function liveStreaming() {
try {
// Step 1: Generate access token
const { accessToken } = await AiolaClient.grantToken({
apiKey: process.env.AIOLA_API_KEY
});
// Step 2: Create client
const client = new AiolaClient({
accessToken: accessToken
});
// Step 3: Start streaming
const connection = await client.stt.stream({
langCode: 'en',
});
connection.on('transcript', (data) => {
console.log('Transcript:', data.transcript);
});
connection.on('connect', async () => {
console.log('Connected to streaming service');
const response = await fetch("https://github.com/aiola-lab/aiola-js-sdk/raw/refs/heads/main/examples/stt/assets/sample-en.wav");
const audioData = await response.arrayBuffer();
connection.send(Buffer.from(audioData));
});
connection.on('disconnect', () => {
console.log('Disconnected from streaming service');
});
connection.on('error', (error) => {
console.error('Streaming error:', error);
});
connection.connect();
} catch (error) {
console.error('Error setting up streaming:', error);
}
}
liveStreaming();
import fs from 'fs';
import { AiolaClient } from '@aiola/sdk';
async function createFile() {
try {
// Step 1: Generate access token
const { accessToken } = await AiolaClient.grantToken({
apiKey: process.env.AIOLA_API_KEY!
});
// Step 2: Create client
const client = new AiolaClient({
accessToken: accessToken
});
// Step 3: Generate audio
const audio = await client.tts.synthesize({
text: 'Hello, how can I help you today?',
voice: 'jess',
language: 'en',
});
const fileStream = fs.createWriteStream('./audio.wav');
audio.pipe(fileStream);
console.log('Audio file created successfully');
} catch (error) {
console.error('Error creating audio file:', error);
}
}
createFile();
import { AiolaClient } from '@aiola/sdk';
async function streamTts() {
try {
// Step 1: Generate access token
const { accessToken } = await AiolaClient.grantToken({
apiKey: process.env.AIOLA_API_KEY!
});
// Step 2: Create client
const client = new AiolaClient({
accessToken: accessToken
});
// Step 3: Stream audio
const stream = await client.tts.stream({
text: 'Hello, how can I help you today?',
voice: 'jess',
language: 'en',
});
const audioChunks: Buffer[] = [];
for await (const chunk of stream) {
audioChunks.push(chunk);
}
console.log('Audio chunks received:', audioChunks.length);
} catch (error) {
console.error('Error streaming TTS:', error);
}
}
streamTts();
a ready-made web app that demonstrates how to use the SDK directly in a browser to stream microphone audio to aiOla Speech-to-Text and receive live transcripts.
cd examples/stt/browser-mic-stream
npm install
npm run dev
AudioWorklet
API to capture microphone audio, convert it to 16-bit PCM (16 kHz, mono), and send it through the WebSocket returned.FAQs
aiOla javascript sdk
The npm package @aiola/sdk receives a total of 182 weekly downloads. As such, @aiola/sdk popularity was classified as not popular.
We found that @aiola/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.