API
Pronunciation assessment API quickstart
Pronunciation assessment: send a recording and the sentence it was meant to be, and get back a score and a word-by-word breakdown of what was heard. Live sessions: follow a recording while it is made, learn when each sentence has been read, and get its assessment.
Before you start
A key, and where to send it
Subscribe on AWS Marketplace to get an
API key, and send it with every call in the x-api-key header. Every call
is a POST to https://pronunciation.ekinox.io. The examples read the key from the
API_KEY environment variable.
Recordings of children may be sent, under 13 included; the consent that takes is yours to obtain. See Recordings of children.
Assess a recording
Assess pronunciation
POST /v1/assess-pronunciation
Evaluates how closely the recorded audio matches the expected text. Returns a score, a list of detected faults, the profile it was assessed under, and a per-word breakdown (status, faults, per-phoneme detail, and mispronounced-grapheme spans for highlighting). Each word and each phoneme carries the millisecond bounds of what was heard for it. They are null for a phoneme no sound was produced for, and for a word nothing was heard of at all, such as an omission. A word's or phoneme's status is correct, mispronounced, omitted or insertion, and this route will only ever send those: a new status would come in a new route under /v2/, beside this one. Submit as multipart/form-data. Supported languages: fr (French), ar (Arabic). A successful assessment is billed by how long its audio lasts, measured from the samples rather than from the WAV header's byte rate; a refused or failed one is not billed.
Request
Sent as multipart/form-data. Multipart form-data with fields: language (string, e.g. 'fr'), audio (16-bit PCM WAV recorded from 8 kHz to 384 kHz, at most 40 seconds and 8 MiB), expectedText (string, at most 200 words and 2000 characters), profile (optional string: the tolerance preset, beginner, standard or advanced, from the most lenient to the strictest; omitted, standard).
| Field | Type | Required |
|---|---|---|
language | string | Yes |
audio | file | Yes |
expectedText | string | Yes |
profile | string | No |
curl
curl -X POST https://pronunciation.ekinox.io/v1/assess-pronunciation \
-H "x-api-key: $API_KEY" \
-F language=fr \
-F audio=@recording.wav \
-F expectedText="Les enfants ont mangé une petite tarte aux pommes."
Python
import os
import requests
response = requests.post(
"https://pronunciation.ekinox.io/v1/assess-pronunciation",
headers={"x-api-key": os.environ["API_KEY"]},
data={"language": "fr", "expectedText": "Les enfants ont mangé une petite tarte aux pommes."},
files={"audio": open("recording.wav", "rb")},
)
response.raise_for_status()
print(response.json()["scorePercent"])
JavaScript (Node.js)
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("language", "fr");
form.append("expectedText", "Les enfants ont mangé une petite tarte aux pommes.");
form.append("audio", new Blob([await readFile("recording.wav")]), "recording.wav");
const response = await fetch("https://pronunciation.ekinox.io/v1/assess-pronunciation", {
method: "POST",
headers: { "x-api-key": process.env.API_KEY },
body: form,
});
if (!response.ok) throw new Error(response.status + " " + (await response.text()));
console.log((await response.json()).scorePercent);
Response
200: Pronunciation assessment result.
| Field | Type | Required |
|---|---|---|
accepted | boolean | Yes |
assessmentVersion | string | Yes |
faults | array of string | Yes |
language | string | Yes |
profile | string | Yes |
scorePercent | number | Yes |
words | array of WordAssessmentResponse | Yes |
WordAssessmentResponse
| Field | Type | Required |
|---|---|---|
endMs | number or null | No |
faults | array of string | Yes |
id | string | Yes |
mispronouncedGraphemes | array of GraphemeSpanResponse | Yes |
phonemes | array of PhonemeAssessmentResponse | Yes |
producedText | string or null | No |
referenceWord | string or null | No |
scorePercent | number or null | No |
startMs | number or null | No |
status | string | Yes |
GraphemeSpanResponse
| Field | Type | Required |
|---|---|---|
end | integer | Yes |
start | integer | Yes |
PhonemeAssessmentResponse
| Field | Type | Required |
|---|---|---|
endMs | number or null | No |
graphemes | GraphemeSpanResponse or null | No |
producedPhoneme | string or null | No |
referencePhoneme | string or null | No |
scorePercent | number | Yes |
startMs | number or null | No |
status | string | Yes |
tolerated | boolean | Yes |
Status codes
| Status | Meaning |
|---|---|
200 | Pronunciation assessment result. |
400 | Invalid request: malformed multipart body (including a missing boundary parameter), missing fields, audio that is not 16-bit PCM WAV, was recorded outside 8 kHz to 384 kHz, or lasts more than 40 seconds, expected text that is blank or over 200 words or 2000 characters, unsupported language, unknown profile, or a field that is not text (send fields as UTF-8), or one sent as a file part over 64 KiB. |
401 | The API key is missing, or is not one we issued. |
403 | The API key is known, but the AWS Marketplace subscription behind it is not active, or does not include this route. |
429 | Too many requests. The Retry-After header says how many seconds to wait. |
500 | Something failed on our side. Quote the errorId to support. |
503 | No server is ready to answer, for example while the service starts. Retry after a short wait. |
413 | The request body is over 8 MiB. 40 seconds of 16 kHz mono WAV is 1.3 MB. |
415 | Content-Type is not multipart/form-data. |
Live sessions
Open a live session
POST /v1/live-sessions
Issues a one-time WebSocket URL for a live session. A live session follows a learner reading aloud and says when each expected sentence has been read, so your application can stop recording, or show the next sentence, without the learner pressing a button. Each sentence read is then assessed, and the assessment sent to you: the same body /v1/assess-pronunciation answers, for that sentence's audio.
Call this from your server, with your API key, and give the browser only the url. It is valid for one connection within 120 seconds and is the only credential the browser needs. Supported languages: fr (French), ar (Arabic, fully vocalized text only).
Billing. Each sentence's assessment is billed by the seconds of audio assessed, as /v1/assess-pronunciation bills a recording of the same length. Following the reading is not billed, nor, usually, the pauses between sentences: there is no need to assess the recording again afterwards.
Limits. Up to maxDurationSeconds of audio (240 at most), no more than 10 seconds without a frame, and a set number of sessions at once per subscription, which support can raise.
The WebSocket.
- Within 10 seconds, send a text frame:
{"type":"start","sentences":["…","…"]}, optionally with"profile": the tolerance preset each sentence is assessed with (words are followed with it, never more strictly thanstandard),beginner,standardoradvanced, from the most lenient to the strictest; omitted,standard. - Stream the microphone as binary frames: 16-bit little-endian mono PCM at 16 kHz, from 20 ms (640 bytes) to 64 KiB each, 100 ms advised. Keep streaming through silences. Audio sent before
start(up to 10 seconds) is kept. - Receive
{"type":"ready",…}with the words kept, then{"type":"sentence-read","sentenceIndex":0,"endsAtMs":1840,"words":[…]}as each sentence is read (endsAtMsmay benull;wordsgives each of its words' status, and where it was heard, in ms).{"type":"word",…}messages are informational. - After each
sentence-read, in the same order, receive{"type":"sentence-assessed","sentenceIndex":0,"startsAtMs":0,"endsAtMs":2090,"assessment":{…}}: the sentence's assessment, its times counted fromstartsAtMson the session's audio. In place ofassessment, an"error"(too-long, over 40 seconds;unassessable;internal) says why there is none, and the session goes on. - Send
{"type":"stop"}to end the session: the sentences already read are assessed and sent, for up to 10 seconds, then it closes with 1000. One not sent by then is not billed, unless its assessment had begun.
Any other close means: let the learner stop by hand. An {"type":"error","code":…} message usually comes first. Close 1013 (capacity, license-capacity) means: try again later, with a new URL. 1008 is invalid-session, unsupported-target, protocol, max-duration or idle; 1011 is internal.
Request
Sent as application/json. The session's language and, optionally, its maximum duration.
| Field | Type | Required |
|---|---|---|
language | string | Yes |
maxDurationSeconds | integer or null | No |
curl
curl -X POST https://pronunciation.ekinox.io/v1/live-sessions \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"language":"fr"}'
Python
import os
import requests
response = requests.post(
"https://pronunciation.ekinox.io/v1/live-sessions",
headers={"x-api-key": os.environ["API_KEY"]},
json={"language":"fr"},
)
response.raise_for_status()
print(response.json()["url"])
JavaScript (Node.js)
const response = await fetch("https://pronunciation.ekinox.io/v1/live-sessions", {
method: "POST",
headers: { "x-api-key": process.env.API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({"language":"fr"}),
});
if (!response.ok) throw new Error(response.status + " " + (await response.text()));
console.log((await response.json()).url);
In the browser
Your server gives the browser the url, and the browser opens it:
const socket = new WebSocket(url);
socket.onopen = () => {
socket.send(JSON.stringify({"type":"start","sentences":["Les enfants ont mangé une petite tarte aux pommes."]}));
// Then stream the microphone as binary frames, as the steps above say.
};
socket.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.type === "sentence-assessed") console.log(message.sentenceIndex, message.assessment);
};
Response
201: The session's WebSocket URL and when it stops being usable.
| Field | Type | Required |
|---|---|---|
expiresAt | string | Yes |
maxDurationSeconds | integer | Yes |
url | string | Yes |
Status codes
| Status | Meaning |
|---|---|
201 | The session's WebSocket URL and when it stops being usable. |
400 | Invalid request: malformed body, unsupported language or duration out of range. |
413 | The request body is too large. |
415 | The body is not sent as application/json. |
401 | The API key is missing, or is not one we issued. |
403 | The API key is known, but the AWS Marketplace subscription behind it is not active, or does not include this route. |
429 | Too many requests. The Retry-After header says how many seconds to wait. |
500 | Something failed on our side. Quote the errorId to support. |
503 | No server is ready to answer, for example while the service starts. Retry after a short wait. |
Errors
When a call is refused
Under 400, 401, 403, 415, 429 or 500, a refused or failed call answers with this body; under 413 or 503, with none.
| Field | Type | Required |
|---|---|---|
error | string | Yes |
errorId | string or null | No |