Sawalni API
APIsDocumentationOpen portal ↗
Omneity Labs API collection ↗Integration quickstart →API keys and playgrounds →
API Reference

Word Alignment API

Get per-word timestamps from audio using phonetic forced alignment. Upload an audio or video file with a transcript, and receive precise start/end times for every word. Powered by the same Sawalign pipeline as the Speech Alignment API.

How It Works

  1. Upload your audio/video file along with the transcript text
  2. Audio is denoised using spectral-gated noise reduction
  3. Words are extracted from the transcript (whitespace-split, order preserved)
  4. Phonetic forced alignment matches each word to audio frames
  5. Per-word timestamps are returned synchronously

Endpoint

text
POST https://api.sawalni.com/v1/speech/word-align

Unlike /v1/speech/align, this endpoint is synchronous — it returns the result directly without job polling.

Request Body

Send a multipart/form-data request with the audio file and text.

ParameterTypeRequiredDescription
audiofileYesAudio or video file (wav, mp3, flac, mp4, mov, mkv, etc.)
textstringYesTranscript text (words extracted, order preserved)

Size limits:

  • Audio: up to 128 MB
  • Text: up to 1 MB

Example — curl

bash
curl -X POST https://api.sawalni.com/v1/speech/word-align \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "audio=@my_recording.wav" \ -F "text=Hello everyone welcome to the presentation"

Example — Python

python
import requests API_KEY = "YOUR_API_KEY" BASE = "https://api.sawalni.com/v1" with open("recording.wav", "rb") as f: resp = requests.post( f"{BASE}/speech/word-align", headers={"Authorization": f"Bearer {API_KEY}"}, files={"audio": ("recording.wav", f, "audio/wav")}, data={"text": "Hello everyone welcome to the presentation"}, ) result = resp.json() for w in result["words"]: print(f"{w['index']:3d} {w['start']:7.3f} → {w['end']:7.3f} {w['word']}")

Example — JavaScript

javascript
const API_KEY = 'YOUR_API_KEY'; const BASE = 'https://api.sawalni.com/v1'; const form = new FormData(); form.append('audio', audioFile); form.append('text', 'Hello everyone welcome to the presentation'); const resp = await fetch(`${BASE}/speech/word-align`, { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}` }, body: form, }); const result = await resp.json(); result.words.forEach(w => { console.log(`${w.index} ${w.start.toFixed(3)} → ${w.end.toFixed(3)} ${w.word}`); });

Response

json
{ "job_id": "abc123", "status": "done", "words": [ { "word": "Hello", "index": 0, "start": 0.320, "end": 0.680 }, { "word": "everyone", "index": 1, "start": 0.720, "end": 1.240 }, { "word": "welcome", "index": 2, "start": 1.400, "end": 1.760 }, { "word": "to", "index": 3, "start": 1.800, "end": 1.920 }, { "word": "the", "index": 4, "start": 1.960, "end": 2.080 }, { "word": "presentation", "index": 5, "start": 2.120, "end": 2.840 } ], "duration": 5.760, "usage": { "audio_bytes": 1567890, "text_bytes": 82 } }

Response Fields

FieldTypeDescription
job_idstringUnique identifier for the alignment
statusstringAlways "done" on success
wordsarrayPer-word alignment results
words[].wordstringThe text token
words[].indexintegerPosition in the original word list
words[].startnumberStart timestamp in seconds (3 decimal places, ~20ms precision)
words[].endnumberEnd timestamp in seconds
durationnumberTotal audio duration in seconds
usageobjectMetering data

Comparison with Speech Alignment

Feature/v1/speech/align/v1/speech/word-align
OutputSRT subtitlesPer-word timestamps
ModeAsync (job polling)Synchronous
SegmentationPause-based groupingIndividual words
Use caseSubtitlesKaraoke, word highlighting, TTS timing

Supported Audio Formats

wav, mp3, flac, ogg, m4a, aac, wma, mp4, mov, mkv, avi, webm, m4v

Audio is automatically converted to 16kHz mono WAV and denoised before alignment.

Error Handling

HTTP CodeMeaning
200Success — word alignments returned
400Invalid input (unsupported format, empty text, file too large)
413Audio file exceeds 128 MB limit
500Internal alignment error

Pricing

Word alignment is metered by audio file size (bytes uploaded) — same rate as speech alignment.

MetricRate
Audio bytes0.1 credits per 1 MB

Use Cases

  • Karaoke-style highlighting — Highlight words as they are spoken
  • Word-level editing — Precise cuts in audio/video editors
  • Pronunciation analysis — Measure word durations for language learning
  • TTS alignment — Sync generated speech to UI animations
  • Accessibility — Word-level captions for hearing-impaired users