Before you start
- Start the local studio, sign in and select a project with test credits.
- Use Node.js 22.12 or later. Choose an empty working directory for the output.
1. Set your project credential
Open the developer console in the local studio, create a project API key and copy it when shown. Start Bash, then run the following commands. Paste the key at the prompt. Run the later commands in that shell.
export VELOSYLL_URL=http://127.0.0.1:8464
read -rsp 'Project API key: ' VELOSYLL_API_KEY
printf '\n'
export VELOSYLL_API_KEY2. Describe one phrase per language
Set language and text for each segment. An optional voice selects a stock voice for that language. The project endpoint accepts 1–12 phrases, up to 500 characters per phrase and 2,000 total, with a maximum rendered duration of 180 seconds.
import { writeFile } from "node:fs/promises";
import process from "node:process";
const key = process.env.VELOSYLL_API_KEY;
if (!key) throw new Error("Set VELOSYLL_API_KEY to a project key.");
const base = (process.env.VELOSYLL_URL || "http://127.0.0.1:8464").replace(
/\/$/,
"",
);
const response = await fetch(base + "/v1/speech/sequence", {
method: "POST",
headers: {
Authorization: "Bearer " + key,
"Content-Type": "application/json",
},
body: JSON.stringify({
segments: [
{ language: "en", text: "Welcome to the studio." },
{ language: "es", text: "Bienvenidos al puerto." },
],
word_timing: true,
}),
signal: AbortSignal.timeout(300_000),
});
if (!response.ok)
throw new Error(response.status + " " + (await response.text()));
const { audio_base64, ...timing } = await response.json();
await writeFile("narration.wav", Buffer.from(audio_base64, "base64"));
await writeFile("narration-cues.json", JSON.stringify(timing, null, 2));
for (const cue of timing.cues) {
console.log(cue.language, cue.start.toFixed(2), cue.end.toFixed(2), cue.text);
}
3. Save and inspect both outputs
Run the file once. Open narration.wav in an audio player and compare its language transition with the second entry in narration-cues.json. Phrase boundaries use one continuous timeline. Word timing uses a local recognition pass.
node narrate.mjsExpected result
The WAV plays both phrases in order. Each cue has the source text, language, start and end times in seconds, and frame offsets.
Troubleshooting
- Some word timestamps are null.
- Use the phrase boundaries for captions. Inspect word_status and show only matched word times. You can omit the recognition pass by setting word_timing to false.
- A project voice ID is rejected.
- Choose a stock voice for narration. Generate a single phrase with an active project grant using the project voice guide.