Custom Spelling

Supported Languages, Regions, and Models

Custom Spelling is supported for all languages, regions, and models.

Custom Spelling lets you customize how words are spelled or formatted in the transcript.

To use Custom Spelling, include custom_spelling in your transcription parameters. The parameter should be a list of dictionaries, with each dictionary specifying a mapping from a word or phrase to a new spelling or format of a word.

1import requests
2import time
3
4base_url = "https://api.assemblyai.com"
5
6headers = {
7 "authorization": "<YOUR_API_KEY>"
8}
9
10with open("./my-audio.mp3", "rb") as f:
11 response = requests.post(base_url + "/v2/upload",
12 headers=headers,
13 data=f)
14
15upload_url = response.json()["upload_url"]
16
17data = {
18 "audio_url": upload_url, # You can also use a URL to an audio or video file on the web
19 "speech_models": ["universal-3-pro", "universal-2"],
20 "language_detection": True,
21 "custom_spelling": [
22 {
23 "from": ["Decarlo"],
24 "to": "DeCarlo"
25 },
26 {
27 "from": ["SQL"],
28 "to": "Sequel"
29 }
30 ]
31}
32
33url = base_url + "/v2/transcript"
34response = requests.post(url, json=data, headers=headers)
35
36transcript_id = response.json()['id']
37polling_endpoint = base_url + "/v2/transcript/" + transcript_id
38
39while True:
40 transcription_result = requests.get(polling_endpoint, headers=headers).json()
41
42 if transcription_result['status'] == 'completed':
43 print(f"Transcript ID:", transcript_id)
44 break
45
46 elif transcription_result['status'] == 'error':
47 raise RuntimeError(f"Transcription failed: {transcription_result['error']}")
48
49 else:
50 time.sleep(3)

The value in the to key is case-sensitive, but the value in the from key isn’t. Additionally, the to key must only contain one word, while the from key can contain multiple words.