Skip to main content

OpenThai 2.1 ASR Edge on a CPU: setup, everyday use, and how to measure it on your own audio

· 8 min read
Kobkrit Viriyayudhakorn
CEO @ iApp Technology

OpenThai 2.1 ASR Edge is a Thai speech-to-text model of 33 million parameters that needs no GPU. This guide shows how to run it on an ordinary computer or server, how to choose its settings, what it is useful for day to day, and how to measure its speed and accuracy on your own recordings before you rely on it. The model and its results are introduced in the launch post.

Times faster than real time, one clip at a time
MacBook Pro (M3 Max), ONNX, fast head, 8 threads60 min in 14.6 s246×
Server CPU, NeMo, fast head, 8 threads60 min in 20 s185×
MacBook Pro (M3 Max), ONNX, accurate head, 8 threads60 min in 20.6 s175×
Server CPU, NeMo, accurate head, 8 threads60 min in 33 s110×
Server CPU, ONNX, fast head, 1 thread78×
CPU only, 32-bit weights, greedy decoding. Server: Intel Xeon Platinum 8468, process pinned to 8 cores, 100 clips of 1 to 30 s. MacBook rows: one run over a 60-minute file cut at pauses. With 8 single-thread workers, one clip per core, the server does 590 times real time in total, about 6 s for an hour of audio.

What you need​

  • A CPU. The model was tested on Linux and on macOS with Apple silicon. No GPU is used.
  • About 0.5 GB of memory while it runs (560 MB with the accurate head, 480 MB with the fast head).
  • About 260 MB of disk for the ONNX files of both heads.
  • Python 3.9 or later and four small libraries. PyTorch is not needed.
  • No internet connection after the download. Audio never leaves the machine.

Three ways to run it​

Best whenWhat you install
iApp APIYou want no setup, or audio up to 8 hours per file from any language or platformNothing; 0.001 IC per second of audio
ONNX RuntimeYou run it on your own machine; the lightest optiononnxruntime, sentencepiece, soundfile, numpy
NVIDIA NeMoYou already use NeMo, or want to fine-tunePyTorch and NeMo; see the model card

The rest of this guide uses ONNX Runtime.

Install and transcribe a file​

pip install onnxruntime sentencepiece soundfile numpy huggingface_hub
hf download iapp/OpenThai2.1-ASR-Edge-20261205 --include "onnx/*" --local-dir OpenThai2.1-ASR-Edge
python OpenThai2.1-ASR-Edge/onnx/edge_onnx.py file OpenThai2.1-ASR-Edge/onnx meeting.wav

The last command prints the file name and its text. It accepts several files at once.

  • File formats. WAV, FLAC, OGG and MP3 are read directly. Audio that is not 16 kHz also needs pip install librosa, which the runner uses to resample. For M4A, MP4 or other formats, convert first: ffmpeg -i input.m4a -ar 16000 -ac 1 input.wav.
  • Long recordings. Audio longer than 300 seconds is cut at pauses into pieces of at most 300 seconds, and the texts are joined. A recording of any length works.
  • The output is Thai text with no punctuation. Numbers come out as Thai words, and English terms mostly in Latin letters.

Choose the settings​

  • Accurate or fast head. The default accurate head (--head tdt) makes fewer mistakes. The fast head (--head ctc) is about 1.7 times as fast and gets about one more character in a hundred wrong. On a server CPU with 8 threads: 110 against 185 times real time.
  • Piece length. Longer pieces give the model more context and better text, at lower speed: about 175 times real time with pieces of at most 28 seconds (--max-piece-s 28), about 40 times with the default 300 seconds. Keep the default for quality; use 28 when speed matters more.
  • Threads. --threads 8 is the default. The model is small, so more threads speed up one clip only a little. On a server, run several single-thread workers instead (next section).

Use it from Python​

import sys
sys.path.insert(0, "OpenThai2.1-ASR-Edge/onnx")
from edge_onnx import EdgeASR, read_audio, transcribe_long

asr = EdgeASR("OpenThai2.1-ASR-Edge/onnx", head="tdt", threads=8)
audio = read_audio("meeting.mp3") # float32, mono, 16 kHz
print(transcribe_long(asr, audio)) # any length, cut at pauses

asr.transcribe(audio) handles one clip of up to about 30 seconds; transcribe_long cuts longer audio first.

Many files on a server: one clip per core​

One worker with 8 threads uses the machine poorly, because the model is too small to split one clip eight ways. Eight workers with one thread each, one clip per core, transcribe about three times as much audio: 590 times real time in total on 8 cores of a server CPU with the fast head, against 185 times for one 8-thread worker with the same head. At that rate, 100 hours of audio in short pieces take about 10 minutes. The example cuts at 28 seconds for that reason; longer pieces give better text and go slower.

import glob, sys
from concurrent.futures import ProcessPoolExecutor

sys.path.insert(0, "OpenThai2.1-ASR-Edge/onnx")
from edge_onnx import EdgeASR, read_audio, transcribe_long

asr = None

def start_worker():
global asr
asr = EdgeASR("OpenThai2.1-ASR-Edge/onnx", head="ctc", threads=1)

def run(path):
return path, transcribe_long(asr, read_audio(path), max_piece_s=28)

if __name__ == "__main__":
files = sorted(glob.glob("recordings/*.wav"))
with ProcessPoolExecutor(max_workers=8, initializer=start_worker) as pool:
for path, text in pool.map(run, files):
print(path, text, sep="\t")

Set max_workers to the number of physical cores. Each worker holds its own copy of the model, about 0.5 GB.

Everyday uses​

TaskHow
Meeting notesRecord with a microphone on the table, not across the room: with far microphones more than half the characters are wrong. Transcribe the file, then summarise or search the text
Class and lecture recordingsUse the default 300-second pieces, which suit long single-speaker talks
Draft subtitles for a videoThe API returns start and end times for each piece of speech; add punctuation and line breaks by hand
Call recordingsThe API reads 8 kHz telephone audio (µ-law WAV) directly
Confidential audioRun it with ONNX Runtime on a machine without internet access; nothing is sent anywhere
Searching an archiveTranscribe a whole folder with one worker per core, then index the text

Where Edge is not the right tool: live captions (use OpenThai 2.1 ASR Streaming or OpenThai ASR Realtime), and meetings where you need to know who said what (use Chinda ASR Pro, which labels speakers).

What an hour of audio costs​

IC per hour of audio, list prices
OpenThai 2.1 ASR Edgefile transcription3.6 IC · about 4.50 THB
Chinda ASR Pro v2file transcription, speaker labels10.8 IC · about 13.50 THB
OpenThai ASR Realtimelive, per connected second18.0 IC · about 22.50 THB
List prices, before VAT, at 1.25 THB per IC. Billed by the second; part of a second counts as a whole second. The 25 IC a new account receives covers about 6.9 hours of Edge audio. Running the open weights on your own CPU costs no credits.

Measure it on your own audio​

Published figures come from public test sets. Your microphones, speakers and vocabulary differ, so measure before you depend on it. Both measurements below take a few minutes.

Speed on your machine​

python OpenThai2.1-ASR-Edge/onnx/edge_onnx.py speed OpenThai2.1-ASR-Edge/onnx meeting.wav
python OpenThai2.1-ASR-Edge/onnx/edge_onnx.py speed OpenThai2.1-ASR-Edge/onnx meeting.wav --head ctc

It transcribes up to the first 5 minutes of the file once to warm up, then three more times, and prints the fastest run as times real time, with the head, the thread count and the machine. Compare with the chart at the top of this post.

Accuracy on your recordings​

  1. Pick 30 to 50 clips of 5 to 30 seconds that look like your real audio: the same microphones, rooms and speakers.
  2. Have a person type what is said in each clip. Write numbers as Thai words, as the model does, or the comparison will count them as errors.
  3. Put the clips in a manifest file, one JSON object per line:
{"audio_filepath": "clips/001.wav", "text": "สวัสดีครับวันนี้เราจะคุยเรื่องงบประมาณ"}
  1. Transcribe every clip. The runner also prints the speed, the median time per clip and the number of empty answers:
python OpenThai2.1-ASR-Edge/onnx/edge_onnx.py decode OpenThai2.1-ASR-Edge/onnx manifest.jsonl predictions.jsonl
  1. Score the result with this script (score_cer.py). It counts the characters that must be inserted, deleted or replaced to turn the model's text into the person's text, after removing spaces and punctuation, and divides by the number of characters in the person's text:
import json, re, sys

def norm(text):
# compare characters only: drop spaces and punctuation, lower-case Latin letters
return re.sub(r"[\s.,!?;:\"'()\[\]\-–—…/]", "", text).lower()

def edits(ref, hyp):
prev = list(range(len(hyp) + 1))
for i, r in enumerate(ref, 1):
cur = [i]
for j, h in enumerate(hyp, 1):
cur.append(min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (r != h)))
prev = cur
return prev[-1]

refs = {r["audio_filepath"]: r["text"] for r in map(json.loads, open(sys.argv[1], encoding="utf-8"))}
errors = chars = 0
for row in map(json.loads, open(sys.argv[2], encoding="utf-8")):
ref, hyp = norm(refs[row["audio_filepath"]]), norm(row["pred_text"])
errors += edits(ref, hyp)
chars += len(ref)
print(f"{len(refs)} clips, {chars} characters, {100 * errors / chars:.2f}% wrong")
python score_cer.py manifest.jsonl predictions.jsonl

How to read the number: on the public test groups the model gets between 5.58% (Isan dialect) and 21.17% (meetings, near microphones) of characters wrong, and 56.19% in meetings recorded with far microphones. A result between 5% and 21% on your audio is in line with those tests. A much higher figure usually points to distant microphones, loud background noise or many English terms. Run the same clips with --head ctc to see what the fast head costs you in accuracy, and through the API or Chinda ASR Pro to compare.

Developed by iApp, launched with AIEAT. The weights are released under the OpenThai Community License 1.0: free for commercial use by organisations earning USD 10 million a year or less; larger organisations contact sale@iapp.co.th.