npm.io
2.9.0 • Published 1 month agoCLI

audiopod

Licence
MIT
Version
2.9.0
Deps
3
Size
713 kB
Vulns
0
Weekly
0

AudioPod Node.js SDK

Official Node.js SDK for AudioPod AI — an all-in-one AI audio platform: music generation, text-to-speech (with directing), voice cloning, stem separation, transcription, speaker separation, noise reduction, and audiobook production.

This SDK is the Platform (API + Agent) surface of AudioPod — the developer entry point alongside the Python SDK, the CLI, and the MCP server. Start free — mint a key, get free credits to try, no card required. API usage is pay-as-you-go ($1 = 7,500 credits, credits never expire).

npm version Node 16+ License: MIT

Installation

npm install audiopod
# or
yarn add audiopod

Quick Start

import AudioPod from "audiopod";

// Reads AUDIOPOD_API_KEY, or pass { apiKey: "ap_your_api_key" }
const client = new AudioPod();

// Text-to-speech
const job = await client.voice.speak({ text: "Welcome to AudioPod.", voiceId: 368 });
const done = await client.voice.waitForCompletion(job.id);
console.log(done.output_url);

Get a key at audiopod.ai/dashboard/account/api-keys.

Text-to-Speech

500+ voices across 85+ languages, with inline directing written straight into the text.

// Emotion, non-verbal sounds, pauses, and pronunciation — all inline in `text`
const job = await client.voice.speak({
  text: '[warm, unhurried] Good evening. [breathe] Tonight, a story. <break time="600ms"/> It begins in Worcester /ˈwʊstər/.',
  voiceId: 368,
});
  • Emotion / delivery — a leading bracket per segment: [whispering, tense] …
  • Non-verbal sounds[laugh] [sigh] [clear throat] [breathe] [cough] [yawn] [chuckle] [gasp] [groan]
  • Pauses<break time="500ms"/> (≤10s each, ≤20 per request)
  • Pronunciation — inline IPA between slashes: Worcester /ˈwʊstər/

Word-level timestamps (for follow-along / karaoke UIs) and Voice Design (create a voice from a text description) are available via the REST API — see the docs.

Voice Cloning

// Instant clone from a 5–30s reference clip
const voice = await client.voice.create({ name: "My Voice", audioFile: "./sample.wav" });

// Reuse the clone for TTS
const job = await client.voice.speak({ text: "Now in my own voice.", voiceId: voice.id });

Voice conversion (voice-to-voice) is available via the REST API — see Voice Changer.

Music Generation

// Duration is not tier-capped (10s–10min; -1 = model-decided)
const job = await client.music.generate({
  prompt: "upbeat synthwave, 120 BPM, driving bassline",
  duration: 60,
});
const song = await client.music.waitForCompletion(job.id);

Stem Separation

Extract individual audio components from a mixed recording.

Available Modes
Mode Stems Output
single 1 Specified stem only (vocals, drums, bass, guitar, piano, other)
two 2 Vocals + Instrumental
four 4 Vocals, Drums, Bass, Other
six 6 Vocals, Drums, Bass, Guitar, Piano, Other
producer 8 + Kick, Snare, Hihat
studio 12 Full production toolkit
mastering 16 Maximum detail
// From a local file (or pass { url: "https://.../song.mp3" })
const result = await client.stems.separate({ file: "./song.mp3", mode: "six" });
for (const [stem, url] of Object.entries(result.download_urls)) {
  console.log(`${stem}: ${url}`);
}

// Isolate just the vocals
const vocals = await client.stems.separate({ file: "./song.mp3", mode: "single", stem: "vocals" });

Audio to MIDI

Convert a mix — or stems you already separated — into MIDI (bass, vocals, piano by default; guitar is opt-in/experimental). It's a starting-point transcription: tidy timing/lengths in your DAW, drums aren't transcribed yet, and dynamics are approximate.

// Standalone: split + transcribe in one call (default stems: bass, vocals, piano)
const result = await client.midi.transcribe({ file: "./song.mp3" });
console.log(result.merged_midi_url);

// Add-on: transcribe stems you already separated (bills the add-on rate only)
const stemJob = await client.stems.separate({ file: "./song.mp3", mode: "six" });
const midiJob = await client.midi.convertFromStemJob(stemJob.id);
for (const [stem, url] of Object.entries(midiJob.midi_urls ?? {})) {
  console.log(`${stem}: ${url}`);
}

Transcription

// Speaker labels + word timestamps
const job = await client.transcription.create({
  url: "https://example.com/meeting.mp3",
  speakerDiarization: true,
  wordTimestamps: true,
});
const result = await client.transcription.waitForCompletion(job.id);

Premium-accuracy transcription and real-time WebSocket streaming (client.transcription.stream(...)) are also supported — see Speech-to-Text.

Other Audio Services

// Speaker separation / diarization
const speakers = await client.speaker.diarize({ url: "https://example.com/interview.wav" });

// Noise reduction
const clean = await client.denoiser.denoise({ file: "./noisy.wav" });

// Audiobook production (manuscript → ACX-ready export)
const project = await client.audiobook.createProject({ title: "My Book", language: "en" });

Audiobooks: paragraph-level control

Narration works at paragraph granularity — project → chapter → paragraph.

// Manuscript parsing is async. waitForParse polls the project and throws
// immediately if the parse failed (instead of hanging forever).
await client.audiobook.waitForParse(projectId);

// One round-trip for the project plus its chapters.
const project = await client.audiobook.getProject(projectId, { includeChapters: true });
const chapterId = project.chapters![0].id;

// Omit page/perPage to get every paragraph in the chapter.
const { paragraphs, total } = await client.audiobook.listParagraphs(projectId, chapterId);

// Narrate a single paragraph (first take billed, first regeneration free).
const take = await client.audiobook.narrateParagraph(projectId, paragraphs[0].id, {
  voiceId: 42,
  direction: "warm, unhurried",
});
const status = await client.audiobook.getParagraph(projectId, paragraphs[0].id);

// Or queue one job for many paragraphs — omit both id lists for the whole project.
const batch = await client.audiobook.batchNarrate(projectId, { voiceId: 42, chapterIds: [chapterId] });

OpenAI-Compatible Endpoints

Already have OpenAI-shaped audio code? Point it at AudioPod — set the client base URL to https://api.audiopod.ai/api/v1 and Authorization: Bearer ap_.... The /audio/speech, /audio/transcriptions, and /audio/translations endpoints behave like their OpenAI counterparts. See OpenAI compatibility.

API Wallet

const balance = await client.wallet.getBalance();
console.log(`Balance: ${balance.balance_usd}`);

const estimate = await client.wallet.estimateCost({ serviceType: "text_to_speech", durationSeconds: 180 });
console.log(`Estimated cost: ${estimate.cost_usd}`);

Error Handling

import AudioPod, {
  InsufficientBalanceError,
  AuthenticationError,
} from "audiopod";

try {
  const client = new AudioPod({ apiKey: "ap_..." });
  const job = await client.voice.speak({ text: "Hello", voiceId: 368 });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.log("Invalid API key");
  } else if (error instanceof InsufficientBalanceError) {
    console.log(`Need more credits. Required: ${error.requiredCents} cents`);
  }
}

Environment Variables

export AUDIOPOD_API_KEY="ap_your_api_key"
// Client reads from env automatically
const client = new AudioPod();

TypeScript Support

Full TypeScript support with exported types:

import AudioPod, { StemExtractionJob, StemMode, WalletBalance } from "audiopod";

Documentation

License

MIT License - see LICENSE for details.

Keywords