Version: 0.1.0
The aiOla TTS Synthesize Test Client provides a simple interface to convert text into speech using the aiOla Text-to-Speech (TTS) API and download the generated audio file.
- Browser:
- Modern browsers (Chrome, Firefox, Edge).
- Must support
AudioWorklet
andWeb Audio API
.
- Server:
- Connection to Aiola backend with a valid API key.
- HTTPS:
- Application must be served over
https://
orlocalhost
to access the microphone.
- Application must be served over
- Download or clone the repository:
git clone https://github.com/aiola-lab/aiola-js-sdk
- Place
aiola_tts_client.js
in your project directory.
The TTS client is initialized with the base API URL:
import AiolaTTSClient from './aiola_tts_client.js';
const baseUrl = 'https://tesla.internal.aiola.ai/api/tts';
const ttsClient = new AiolaTTSClient(baseUrl);
The synthesize method is used to generate the audio:
const audioBlob = await ttsClient.synthesize(text, voice);
The audio file is made downloadable using:
const audioUrl = URL.createObjectURL(audioBlob);
const link = document.createElement('a');
link.href = audioUrl;
link.download = 'synthesized_audio.wav';
The synthesizeStream method is used for real-time streaming:
const audioBlob = await ttsClient.synthesizeStream(text, voice);
The streamed audio is played directly in the browser using:
audioPlayer.src = URL.createObjectURL(audioBlob);
audioPlayer.play();
### Customization
To change the list of voices, update the \<select\> element in index.html:
```html
<option value="af_bella">Bella</option>
<option value="af_nicole">Nicole</option>