Guides
Pronunciation assessment
Compare a recording with the text the speaker was asked to read, and get scores for the whole utterance, every word and every phoneme, with timings.
Endpoint
POSThttps://api.taktikvoice.com/service/pronunciation
Send a JSON body with Content-Type: application/json and your token in Authorization: Bearer <token> (Authentication). Limit: 10 requests per minute per client IP (Rate limits).
Request body
| Field | Type | Description |
|---|---|---|
audio_base64required | string | The recording as a WAV file, base64-encoded. Recommended: PCM 16-bit, 16 kHz, mono (other sample rates are resampled to 16 kHz and stereo is mixed down to mono). At least 0.1 seconds; keep it to a sentence, because processing is cut off at about 30 seconds. Send the plain base64 string, without a data: URI prefix. |
transcriptrequired | string | The text the speaker was asked to read. Must not be empty. |
languageoptional | "us" | "uk" | Reference accent: uk (British English, default) or us (American English). Any other value returns 400. Default: "uk". |
Audio format
Recommended format (it’s what the model works on, so nothing has to be converted):
- Container: WAV (RIFF).
- Encoding: PCM, signed 16-bit.
- Sample rate: 16,000 Hz. Other sample rates are resampled to 16 kHz.
- Channels: 1 (mono). Stereo is mixed down to mono.
- Encoding in JSON: standard base64 of the whole file, as a plain string. Don’t add a
data:audio/wav;base64,prefix.
Length: at least 0.1 seconds. There’s no fixed maximum, but processing is cut off at about 30 seconds, so keep each recording to one sentence. A recording that takes too long usually comes back as 500 (see Errors).
To convert a file from another format:
# Any input format → plain WAV: PCM 16-bit, 16 kHz, mono, no metadata chunks
ffmpeg -i input.m4a -ac 1 -ar 16000 -c:a pcm_s16le -map_metadata -1 -fflags +bitexact sample.wavRecording in the browser? Capture the microphone, resample to 16 kHz mono 16-bit and wrap it in a WAV header before uploading it to your backend. That’s what the live demo does.
Example request
Read sample.wav, send it with the sentence that was read, and print the scores:
# The JSON body is written to a file: long recordings don't fit in a shell argument.
printf '{"transcript":"Could you send the proposal by Thursday?","language":"us","audio_base64":"%s"}' \
"$(base64 < sample.wav | tr -d '\n')" > body.json
curl -sS -X POST https://api.taktikvoice.com/service/pronunciation \
-H "Authorization: Bearer $TAKTIK_TOKEN" \
-H "Content-Type: application/json" \
--data @body.json// Node.js 18+ (server-side only: never ship your token to a browser)
import { readFile } from 'node:fs/promises'
const audio = await readFile('sample.wav')
const response = await fetch('https://api.taktikvoice.com/service/pronunciation', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.TAKTIK_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
audio_base64: audio.toString('base64'),
transcript: 'Could you send the proposal by Thursday?',
language: 'us',
}),
})
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`)
const result = await response.json()
console.log(`Overall: ${Math.round(result.accuracy * 100)}%`)
for (const word of result.words) {
const missed = word.phonemes.filter(phoneme => !phoneme.correct).map(phoneme => phoneme.text)
console.log(word.text, Math.round(word.accuracy * 100), missed.length ? `check: /${missed.join(' ')}/` : '')
}# Python 3 with requests (pip install requests)
import base64
import os
import requests
with open("sample.wav", "rb") as f:
audio_base64 = base64.b64encode(f.read()).decode("ascii")
response = requests.post(
"https://api.taktikvoice.com/service/pronunciation",
headers={"Authorization": f"Bearer {os.environ['TAKTIK_TOKEN']}"},
json={
"audio_base64": audio_base64,
"transcript": "Could you send the proposal by Thursday?",
"language": "us",
},
timeout=60,
)
response.raise_for_status()
result = response.json()
print(f"Overall: {round(result['accuracy'] * 100)}%")
for word in result["words"]:
missed = [p["text"] for p in word["phonemes"] if not p["correct"]]
print(word["text"], round(word["accuracy"] * 100), f"check: /{' '.join(missed)}/" if missed else "")Response
A successful request returns 200 with this JSON:
| Field | Type | Description |
|---|---|---|
accuracyrequired | number (0–1) | Overall pronunciation score for the utterance: correct phonemes divided by all phonemes, from 0 to 1 (higher is better). |
wordsrequired | array of WordScore | One entry per word of the normalised transcript, in order. |
words[].textrequired | string | The word after normalisation: punctuation removed and numbers spelled out (21 becomes twenty and one), so words can have more entries than the transcript has words. |
words[].accuracyrequired | number (0–1) | Share of the word’s phonemes that were pronounced correctly, from 0 to 1. |
words[].start_timerequired | number | Start of the word in the audio, in seconds. |
words[].end_timerequired | number | End of the word in the audio, in seconds. |
words[].phonemesrequired | array of PhonemeScore | The expected phonemes of the word, in order (the most likely pronunciation in the reference pronunciation lexicon). A word missing from the pronunciation lexicon comes back with a single phoneme whose text is an empty string and correct is false. |
words[].phonemes[].textrequired | string | The expected phoneme, in IPA. Empty string when the word is not in the reference pronunciation lexicon. |
words[].phonemes[].start_timerequired | number | Start of the phoneme in the audio, in seconds. Can be 0 when the phoneme was not detected. |
words[].phonemes[].end_timerequired | number | End of the phoneme in the audio, in seconds. Can be 0 when the phoneme was not detected. |
words[].phonemes[].probabilityrequired | number (0–1) | Model probability for this phoneme, from 0 to 1. It is a confidence value, not a grade: use correct to decide whether the phoneme was pronounced as expected. |
words[].phonemes[].correctrequired | boolean | Whether the phoneme was pronounced as expected. |
words[].phonemes[].expectedrequired | array of string | Accepted pronunciation(s) of this phoneme, in IPA. |
words[].phonemes[].candidatesrequired | array of PhonemeCandidate | Other phonemes the model heard, with their probability. Often empty. |
words[].phonemes[].candidates[].valuerequired | string | Phoneme the model heard, in IPA. |
words[].phonemes[].candidates[].probabilityrequired | number (0–1) | Model probability for this candidate, from 0 to 1. |
Reading the scores
- Every score is a number from 0 to 1. Multiply by 100 for a percentage.
- Use
correctto decide whether a phoneme was pronounced as expected.probabilityis the model’s confidence, not a grade: a correct phoneme can have a modest probability. - When
correctisfalse,candidatescan list what the model heard instead, each with its probability. - A phoneme that wasn’t detected at all can come back with
start_timeandend_timeof0andprobability0, as in the example below. - Phonemes are written in IPA. Times are in seconds from the start of the recording.
- A word’s
accuracyis the share of its phonemes that arecorrect; the overallaccuracyis correct phonemes divided by all phonemes.
How words are listed
words[].textis the word after normalisation, not as written: punctuation is removed and numbers are spelled out (21becomestwentyandone). Sowordscan have more entries than your transcript has words: don’t assumewords[i]is the i-th word you sent.- Each word is scored against its most likely pronunciation in the reference pronunciation lexicon for the chosen accent; alternative pronunciations aren’t accepted.
- A word that isn’t in the reference pronunciation lexicon comes back with a single phoneme whose
textis"", withcorrect: falseandexpected: [""]. It scores0and lowers the overallaccuracy, so treat it as “not scored” rather than “mispronounced”.
Example response
Excerpt of a real response for “Could you send the proposal by Thursday?” (the first word and the word with a missed phoneme):
{
"accuracy": 0.96,
"words": [
{
"text": "Could",
"phonemes": [
{
"text": "kʰ",
"start_time": 0.2405,
"end_time": 0.2605,
"probability": 0.9956,
"correct": true,
"expected": [
"kʰ"
],
"candidates": []
},
{
"text": "ʊ",
"start_time": 0.2806,
"end_time": 0.3006,
"probability": 0.6448,
"correct": true,
"expected": [
"ʊ"
],
"candidates": []
},
{
"text": "d",
"start_time": 0.3407,
"end_time": 0.3808,
"probability": 0.4019,
"correct": true,
"expected": [
"d"
],
"candidates": []
}
],
"start_time": 0.2405,
"end_time": 0.3808,
"accuracy": 1
},
{
"text": "Thursday",
"phonemes": [
{
"text": "θ",
"start_time": 1.6634,
"end_time": 1.6834,
"probability": 0.9876,
"correct": true,
"expected": [
"θ"
],
"candidates": []
},
{
"text": "ɝ",
"start_time": 1.7035,
"end_time": 1.7235,
"probability": 0.9863,
"correct": true,
"expected": [
"ɝ"
],
"candidates": []
},
{
"text": "z",
"start_time": 1.944,
"end_time": 1.964,
"probability": 0.9938,
"correct": true,
"expected": [
"z"
],
"candidates": []
},
{
"text": "d",
"start_time": 1.9841,
"end_time": 2.0241,
"probability": 0.9592,
"correct": true,
"expected": [
"d"
],
"candidates": []
},
{
"text": "ej",
"start_time": 0,
"end_time": 0,
"probability": 0,
"correct": false,
"expected": [
"ej"
],
"candidates": [
{
"value": "h/ç",
"probability": 0.0103
}
]
}
],
"start_time": 1.6634,
"end_time": 2.0241,
"accuracy": 0.8
}
]
}Errors
A malformed body returns 422; audio or values the service can’t use (for example a language other than us/uk) return 400; a bad token 401; too many requests 429; a busy or starting service 503; a recording that takes too long 500 or 504. Some of these bodies are double-encoded. See Errors for each case, how to parse them and when to retry.