FFmpeg Automation API

Convert and process audio directly through the Kokoro infrastructure. These endpoints expose the same FFmpeg helpers we use internally so you can automate WAV → MP3 conversion and tempo changes without maintaining a custom media server.

Available endpoints

MethodPathDescription
POST/api/v1/ffmpeg/wav-to-mp3Convert base64 WAV input into MP3 with a selectable bitrate.
POST/api/v1/ffmpeg/speedAdjust playback speed (0.25x–5x) and optionally return MP3.

Both endpoints require the same bearer token used by the speech API. Swagger docs live at /api/v1/index.html.

Preparing payloads

  • Encode the WAV file you want to process with base64 (example below).
  • Strip newlines so the JSON body stays compact: BASE64_WAV=$(base64 -i input.wav | tr -d '\n').
  • Send the value in the audio field. The API validates RIFF/WAVE headers.
  • Set response_type to base64 for JSON output or omit it to receive a binary stream.

WAV → MP3 conversion

Supply a base64 WAV payload and optionally override the bitrate (defaults to 192k). Use response_type=base64 when testing from terminals, or keep the binary response to pipe directly to a file.

Request fields

FieldRequiredDescription
audioYesBase64-encoded WAV file.
bitrateNoFFmpeg bitrate such as 128k, 192k, 320k.
response_typeNobinary (default) or base64.

curl example

BASE64_WAV=$(base64 -i input.wav | tr -d '
')
curl -X POST   https://kokoro.lancesmith.cc/api/v1/ffmpeg/wav-to-mp3   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   --data '{
    "audio": "'"$BASE64_WAV"'",
    "bitrate": "256k",
    "response_type": "base64"
  }'

Speed adjustment

Send a WAV payload plus the desired multiplier. The API returns WAV by default, or MP3 when output_format is set to mp3 (you can also pick a bitrate).

Request fields

FieldRequiredDescription
audioYesBase64 WAV payload.
speedYesMultiplier between 0.25 and 5.
output_formatNowav (default) or mp3.
bitrateNoOnly used when returning MP3.
response_typeNobinary (default) or base64.

curl example

BASE64_WAV=$(base64 -i input.wav | tr -d '
')
curl -X POST   https://kokoro.lancesmith.cc/api/v1/ffmpeg/speed   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   --data '{
    "audio": "'"$BASE64_WAV"'",
    "speed": 1.25,
    "output_format": "mp3",
    "response_type": "base64"
  }'

Node example

import fs from "fs";

const wav = await fs.promises.readFile("input.wav");
const base64 = wav.toString("base64");

const response = await fetch("https://kokoro.lancesmith.cc/api/v1/ffmpeg/speed", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    audio: base64,
    speed: 0.8,
    output_format: "mp3",
    response_type: "base64",
  }),
});

if (!response.ok) {
  throw new Error(`FFmpeg API failed: ${response.status}`);
}

const payload = await response.json();
await fs.promises.writeFile("slower.mp3", Buffer.from(payload.audio, "base64"));

Need more?

Let us know if you need additional FFmpeg routines exposed—transcoding, trimming, mixing, or waveform analytics can be added using the same pattern.