### Run Browser-based Speech-to-Text Example Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Instructions to set up and run a browser-based example demonstrating live microphone audio streaming to aiOla Speech-to-Text. It outlines the necessary commands to navigate to the example directory, install dependencies, and start the development server. ```bash cd examples/stt/browser-mic-stream npm install npm run dev ``` -------------------------------- ### Quick Start for Text-to-Speech with aiOla SDK Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/examples/tts/README.md This quick start example demonstrates how to use the aiOla SDK for text-to-speech functionality. It covers two main use cases: synthesizing audio to a local file and streaming audio chunks. The client is initialized with an API key, and both methods showcase basic TTS synthesis with specified text, voice, and language. ```typescript import { AiolaClient } from '@aiola/sdk'; import fs from 'node:fs'; const client = new AiolaClient({ apiKey: process.env.AIOLA_API_KEY, }); async function synthesizeToFile() { const audioStream = await client.tts.synthesize({ text: "Hello, how can I help you today?", voice: "jess", language: "en", }); // Save to file const fileStream = fs.createWriteStream("./output.wav"); audioStream.pipe(fileStream); fileStream.on('finish', () => { console.log("Audio file saved successfully!"); }); fileStream.on('error', (error) => { console.error("Error saving file:", error); }); } async function streamTts() { const stream = await client.tts.stream({ text: "Hello, this is a streaming example of text-to-speech synthesis.", voice: "jess", language: "en", }); // Collect audio chunks const audioChunks = []; for await (const chunk of stream) { audioChunks.push(chunk); } // Process chunks as needed (e.g., play audio, save to buffer, etc.) } ``` -------------------------------- ### Install aiOla SDK using npm or yarn Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Instructions for installing the aiOla JavaScript SDK using either npm or yarn package managers. ```bash npm install @aiola/sdk # or yarn add @aiola/sdk ``` -------------------------------- ### Quick Start: aiOla SDK Speech-to-Text Transcription and Streaming Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/examples/stt/README.md This example demonstrates how to use the aiOla SDK for both transcribing an audio file and setting up a real-time audio stream for live speech-to-text transcription. It includes client initialization, file system interaction, and handling streaming connection events for various events like transcript updates, connection status, and errors. ```ts import { AiolaClient } from '@aiola/sdk'; import fs from 'node:fs'; import path from "path"; const client = new AiolaClient({ apiKey: AIOLA_API_KEY, }); const filePath = path.resolve(__dirname, "./audio.wav"); // Transcribe an audio file to text async function transcribeFile() { const audioFile = fs.createReadStream(filePath); const transcript = await client.stt.transcribeFile({ file: audioFile, language: "en" }); console.log(transcript); } // Stream audio in real-time for live transcription async function liveStreaming() { const connection = await client.stt.stream({ langCode: 'en', }); connection.on('transcript', (data) => { console.log('Transcript:', data.transcript); }); connection.on('connect', () => { console.log('Connected to streaming service'); }); connection.on('disconnect', () => { console.log('Disconnected from streaming service'); }); connection.on('error', (error) => { console.error('Streaming error:', error); }); connection.connect(); const audioFile = fs.createReadStream(filePath); audioFile.on('data', (chunk) => { connection.send(chunk); }); audioFile.on('end', () => { connection.disconnect(); }); audioFile.on('error', (error) => { console.error('File read error:', error); }); } ``` -------------------------------- ### Local Testing of Automated Release Process Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/RELEASE.md Commands to set up and perform a dry run of the automated release process locally. This includes installing project dependencies, configuring the NPM token, and executing a dry run of semantic-release to simulate a release without publishing. ```Shell # Install dependencies npm install # Set NPM token export NPM_TOKEN=your_token_here # Test release (dry run) npx semantic-release --dry-run ``` -------------------------------- ### Conventional Commits: Message Format and Breaking Changes Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/RELEASE.md Defines the standard format for commit messages, adhering to the Conventional Commits specification, which is crucial for automating version bumping and changelog generation. Includes an example of how to indicate a breaking change. ```Text [optional scope]: [optional body] [optional footer(s)] ``` ```Text feat: add new API method BREAKING CHANGE: The old API method has been removed ``` -------------------------------- ### Instantiate aiOla Client with API Key Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Demonstrates how to create a new AiolaClient instance by providing an API key for authentication. ```ts import { AiolaClient } from '@aiola/sdk'; const client = new AiolaClient({ apiKey: AIOLA_API_KEY, }); ``` -------------------------------- ### Instantiate aiOla Client with Access Token Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Shows how to initialize the AiolaClient using an existing access token, useful for client-side authentication after token generation. ```ts const client = new AiolaClient({ accessToken: YOUR_ACCESS_TOKEN, }); ``` -------------------------------- ### Rollback Procedures for Bad Releases Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/RELEASE.md Commands to revert a faulty release in emergency situations. This involves unpublishing the package from npm, deleting the corresponding GitHub release, and force pushing to remove the associated Git tag. ```Shell npm unpublish @aiola/sdk@version ``` ```Shell git push origin :refs/tags/v1.2.3 ``` -------------------------------- ### GitHub Secrets Configuration for Automated Release Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/RELEASE.md Details the essential GitHub secrets required for the automated release workflow. These secrets, NPM_TOKEN and GITHUB_TOKEN, enable publishing to npm and interacting with the GitHub API respectively. ```APIDOC GitHub Secrets: NPM_TOKEN: - Description: Token for publishing packages to npm. - Setup: Create an "Automation" token at https://www.npmjs.com/settings/tokens and add it to GitHub repository secrets. GITHUB_TOKEN: - Description: Automatically provided token for GitHub API interactions (e.g., creating releases, tagging). - Setup: Automatically available in GitHub Actions workflows. ``` -------------------------------- ### Perform Live Speech-to-Text Streaming Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Illustrates how to establish a live speech-to-text streaming connection with the aiOla API. It sets up an event listener for transcripts and continuously sends audio chunks from a file stream to the connection. ```ts import { AiolaClient } from '@aiola/sdk'; import fs from 'node:fs'; const client = new AiolaClient({ apiKey: AIOLA_API_KEY, }); const connection = await client.stt.stream({ lang_code: 'en', }); connection.on('transcript', ({ transcript }) => { console.log('Transcript:', transcript); }); const audio = fs.createReadStream('./audio.wav'); audio.on('data', (chunk) => connection.send(chunk)); connection.connect(); ``` -------------------------------- ### Configure Custom Base URL for aiOla Client Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Explains how to direct the AiolaClient to a custom API endpoint by specifying the `baseUrl` option during instantiation, typically used in enterprise environments. ```ts const client = new AiolaClient({ apiKey: AIOLA_API_KEY, baseUrl: 'https://api.mycompany.aiola.ai', }); ``` -------------------------------- ### Synthesize Text-to-Speech and Save to File Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Shows how to use the aiOla SDK's text-to-speech functionality to synthesize audio from text and save it to a local file. It specifies the text, voice, and language, then pipes the audio stream to a file writer. ```ts import fs from 'node:fs'; async function createFile() { 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); } createFile(); ``` -------------------------------- ### Perform Speech-to-Text Transcription from File Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Demonstrates how to use the aiOla SDK to transcribe an audio file (e.g., WAV) into text. It reads the file as a stream and sends it to the `stt.transcribeFile` method, logging the resulting transcript. ```ts import fs from 'node:fs'; import path from "path"; async function transcribeFile() { const filePath = path.resolve(__dirname, "./audio.wav"); const file = fs.createReadStream(filePath); const transcript = await client.stt.transcribeFile({ file: file, language: "en" }); console.log(transcript); } transcribeFile(); ``` -------------------------------- ### Generate Temporary Access Token for aiOla Client Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Illustrates how to generate a temporary access token from an API key using the AiolaClient's static grantToken method. This is beneficial for backend-frontend separation, enhanced security, and custom token management. ```ts const accessToken = await AiolaClient.grantToken(AIOLA_API_KEY); const client = new AiolaClient({ accessToken }); ``` -------------------------------- ### Stream Text-to-Speech Audio Chunks Source: https://github.com/aiola-lab/aiola-js-sdk/blob/main/README.md Demonstrates how to stream text-to-speech audio from the aiOla API. It synthesizes audio from text, voice, and language, then iterates through the incoming audio chunks, collecting them in an array. ```ts async function streamTts() { const stream = await client.tts.stream({ text: 'Hello, how can I help you today?', voice: 'jess', language: 'en', }); const audioChunks = []; for await (const chunk of stream) { audioChunks.push(chunk); } } streamTts(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.