Speaker diarization API: who said what, and when
Every sentence comes back with its speaker and its start and end time, from a file, a link or a live stream. Name a speaker once and save them, and later recordings put their name on their lines.
npm install @vocalstack/js-sdkimport { VocalStack } from '@vocalstack/js-sdk';
const vs = new VocalStack({ apiKey: process.env.VOCALSTACK_API_KEY });
const tx = await vs.transcriptions.create({
file: './meeting.mp3',
settings: { speakerLabels: 'on' },
});
const job = await vs.transcriptions.waitForJob(tx.id);
if (job.state !== 'done') throw new Error(`transcription ${job.state}`);
const { sentences, speakers } = await vs.transcriptions.transcript(tx.id);
const who = new Map(speakers.map((s) => [s.speaker, s.name || `Speaker ${s.number}`]));
for (const s of sentences) console.log(`${who.get(s.speaker)}: ${s.text}`);
// Remember the first speaker by their voice fingerprint. No clone without consent.
await vs.speakers.createFromAppearance({
transcriptionId: tx.id,
appearance: 0,
name: 'Dana',
consent: false,
});Speaker 1: Thanks for joining. Let's start with the quarterly numbers.
Speaker 2: Revenue was up twelve percent on the last quarter.
Speaker 1: Good. What drove most of it?
Speaker 3: Mostly the two new markets we opened in spring.What the speaker labels give you
Speaker labels come with every transcription at no extra cost. Set speakerLabels to choose when lines are labelled.
A speaker on every sentence
Sentences and segments carry a
speakernumber, and segments carry the start and end of every word. The transcript lists each speaker with how long they spoke.Live as well as recorded
In a live session each line arrives with its speaker. When more of a voice confirms or changes a label a moment later, a
transcript.speakerframe says so.When needed, on or off
auto, the default, labels lines once a second voice is heard, so a talk by one person reads clean.onlabels every line andofflabels none.Names that stay put
Name a speaker and the name appears on all their lines, in every recording of that transcription. Listeners following live see it at once.
Saved speakers, recognised later
Save a speaker from a transcription or from a sample with 20 seconds of their speech. Their voice fingerprint is kept, and later transcriptions label them by name. Pay as you go keeps saved speakers for 30 days, Premium until you delete them.
Their own voice, only with consent
With the person's consent, a saved speaker's voice can be cloned to read translations of their own words. Without it, no voice is cloned: their name, fingerprint and sample are kept.
100 languages
Speaker labels work in every language the API transcribes, and a translated transcript keeps each line's speaker.
Exports with speakers
PDF, XLSX, SRT, VTT, TXT, Markdown and JSON exports show who spoke, or leave it out with
speakerLabels=off.
The calls behind it
Speaker labels are a setting on the transcription. Naming and saving speakers are calls of their own.
- POST
/v1/transcriptionsCreate a transcription withsettings.speakerLabelsset toauto,onoroff. - GET
/v1/transcriptions/{id}/transcriptSentences and segments with theirspeaker, andspeakerswith each one's number, name and seconds spoken. - PUT
/v1/transcriptions/{id}/appearances/{number}Name a speaker in this transcription, in every recording of it. - POST
/v1/speakers/from-appearanceSave a speaker heard in a transcription; their speech there is the sample, no upload. - POST
/v1/speakersSave a speaker from an uploaded sample with at least 20 seconds of their speech. - GET
/v1/speakersList saved speakers, with the cloned voice of each one who agreed to it. - DELETE
/v1/speakers/{id}Delete a saved speaker, with their fingerprint, sample and cloned voice.
Billed per second of audio
Speaker labels, names and saved speakers cost nothing extra. You pay for the audio transcribed, by the second.
- Pay as you go bills at least 5 minutes for each transcription.
- Premium and Enterprise bill every second with no minimum.
- New accounts get $5 of credit to try it.
Frequently Asked Questions
Guides and related pages
The API reference has complete programs for every SDK and for plain HTTP.