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

Request body fields
FieldTypeDescription
audio_base64requiredstringThe 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.
transcriptrequiredstringThe 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:

Shell
# 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.wav

Recording 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

Response

A successful request returns 200 with this JSON:

Response fields
FieldTypeDescription
accuracyrequirednumber (0–1)Overall pronunciation score for the utterance: correct phonemes divided by all phonemes, from 0 to 1 (higher is better).
wordsrequiredarray of WordScoreOne entry per word of the normalised transcript, in order.
words[].textrequiredstringThe 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[].accuracyrequirednumber (0–1)Share of the word’s phonemes that were pronounced correctly, from 0 to 1.
words[].start_timerequirednumberStart of the word in the audio, in seconds.
words[].end_timerequirednumberEnd of the word in the audio, in seconds.
words[].phonemesrequiredarray of PhonemeScoreThe 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[].textrequiredstringThe expected phoneme, in IPA. Empty string when the word is not in the reference pronunciation lexicon.
words[].phonemes[].start_timerequirednumberStart of the phoneme in the audio, in seconds. Can be 0 when the phoneme was not detected.
words[].phonemes[].end_timerequirednumberEnd of the phoneme in the audio, in seconds. Can be 0 when the phoneme was not detected.
words[].phonemes[].probabilityrequirednumber (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[].correctrequiredbooleanWhether the phoneme was pronounced as expected.
words[].phonemes[].expectedrequiredarray of stringAccepted pronunciation(s) of this phoneme, in IPA.
words[].phonemes[].candidatesrequiredarray of PhonemeCandidateOther phonemes the model heard, with their probability. Often empty.
words[].phonemes[].candidates[].valuerequiredstringPhoneme the model heard, in IPA.
words[].phonemes[].candidates[].probabilityrequirednumber (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 correct to decide whether a phoneme was pronounced as expected. probability is the model’s confidence, not a grade: a correct phoneme can have a modest probability.
  • When correct is false, candidates can list what the model heard instead, each with its probability.
  • A phoneme that wasn’t detected at all can come back with start_time and end_time of 0 and probability 0, as in the example below.
  • Phonemes are written in IPA. Times are in seconds from the start of the recording.
  • A word’s accuracy is the share of its phonemes that are correct; the overall accuracy is correct phonemes divided by all phonemes.

How words are listed

  • words[].text is the word after normalisation, not as written: punctuation is removed and numbers are spelled out (21 becomes twenty and one). So words can have more entries than your transcript has words: don’t assume words[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 text is "", with correct: false and expected: [""]. It scores 0 and lowers the overall accuracy, 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):

200 OK
{
  "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.