Tools,

Urdu OCR: ten free Tesseract runs, tested

36.7%

of letters at best: urd best, Sauvola threshold

Get the command

Best of ten: urd best, Sauvola

We ran Tesseract 5.5.4 on 30 proofread Urdu pages from 7 books on ur.wikisource.

30 pages: letters in order and whole words right
Run Letters Words
urd best, Sauvola threshold 36.7% 10.1%
urd best 34.2% 9.8%
urd best, --psm 6 34.1% 9.3%
urd (fast) 31.7% 8.8%
urd, tessdata repo 31.7% 8.8%
script/Arabic (fast) 27.5% 7.3%
script/Arabic best 26.5% 7.1%
ara (Arabic) 23.0% 1.4%
fas (Persian) 21.2% 2.5%
urd+eng 18.3% 5.6%
A page from another book, Sauvola 24.6% 7.7%

The last row is noise: common letters and words line up by chance.

On these scans, not upscaled, Sauvola added 794 letters to urd best; --psm 6 lost 26.

The command: urd best, Sauvola

curl -LO https://raw.githubusercontent.com/tesseract-ocr/tessdata_best/4.1.0/urd.traineddata
mkdir -p tessdata && mv urd.traineddata tessdata/
tesseract page.png page --tessdata-dir tessdata -l urd -c thresholding_method=2

It writes page.txt, in reading order. thresholding_method=2 is Sauvola. The 8.0 MB model took a median 3.5 s a page.

Homebrew's brew install tesseract-lang has the fast urd, a 1.4 MB file. It read 31.7% of letters and 8.8% of words.

ara and fas lack Urdu letters: skip them

ara, the Arabic model, has none of the six Urdu letters below. fas, the Persian model, lacks four.

Six common Urdu letters on our 30 pages
Letter Times Not in
ی choti ye 2,852 ara
ک kaf 2,225 ara
ہ gol he 1,967 ara, fas
ے bari ye 1,559 ara, fas
ھ do-chashmi he 804 ara, fas
ں noon ghunna 377 ara, fas

Both also lack ٹ, ڈ and ڑ. In all, ara cannot write 35.6% of the letters on our pages, fas 15.9%.

ara wrote the Arabic ي, ك and ه instead. Folding those into the Urdu letters adds 4.2 points. It still trails the fast urd.

Most misses are letters left out

The top run wrote about half as many letters as the pages hold: 16,171 of 31,897.

On 5 pages it wrote a third of the letters or fewer. Three are from the dense 1954 book.

Of the one-letter slips, the top six are letters left out. The first swap is و read as د.

Each book: 26.1% to 54.7%

Each book: letters found
Year on file urd best, Sauvola urd best
1801 text, later Lahore lithograph, undated 40.9% 41.3%
1864, Nastaliq, black and white 38.8% 41.0%
1904, typeset Naskh, small scan 54.7% 52.0%
1910, Nastaliq, boxed verse 26.1% 25.7%
1920, upright letters, small scan 34.3% 33.0%
1929, large upright letters, small scan 52.7% 45.6%
1954, tiny dense Nastaliq, small scan 28.4% 21.4%

A small scan here is a page image under 700 px wide. Its PDF holds no larger one.

Not upscaled, Sauvola beat urd best on 5 of 7 books, most on the 1929 and 1954 books. Upscaled 2x, urd best comes close to Sauvola, but not past it.

A scanned PDF: the same setup

mkdir -p tessdata
cp -r "$(brew --prefix)/share/tessdata/configs" tessdata/
curl -L -o tessdata/urd.traineddata \
  https://raw.githubusercontent.com/tesseract-ocr/tessdata_best/4.1.0/urd.traineddata
TESSDATA_PREFIX=$PWD/tessdata ocrmypdf -l urd --jobs 3 \
  --tesseract-thresholding sauvola --sidecar book.txt scan.pdf book.pdf

It took 34.8 s on our 30-page PDF.

The same text, read back five ways
From Letters in order Words
book.txt 36.1% 9.9%
book.pdf, pdftotext 35.1% 8.8%
book.pdf, pdftotext -raw 34.4% 9.5%
book.pdf, pdftotext -layout 34.8% 8.8%
book.pdf, PDFKit (macOS) 27.3% 9.9%

PDFKit gave 4,235 of the 5,992 words in reverse order along their line. Search book.txt.

pdftotext also adds 2,634 invisible direction marks.

Without the cp line, OCRmyPDF stopped with TesseractConfigError.

Five more things we checked

How we ran it
  • Pages marked proofread or validated on ur.wikisource: every book with two or more such pages but one, which is in Arabic. That makes 7 books.
  • 4 or 5 pages a book, from a seeded shuffle. Pages with footnote tags, tables or templates in the wiki text, or a passage typed twice, were left out.
  • Years are from the file data, not checked against the books. Every page is print. We looked at each one first.
  • On 25 of 30 pages, the top run's text matched its own proofread text better than any other page's. On the other 5 it wrote a third of the letters or fewer.
  • For those pages we checked the first and last lines of the proofread text against the scan by eye. They match.
  • Pages came from PDFs, drawn up to 1,920 px wide.
  • Scores count Urdu letters, hamza included. Vowel marks, digits, punctuation, Latin letters and spaces are left out. Text is compared after Unicode NFC.
  • Strict scores: ي is not ی. Folding Arabic forms into Urdu ones moved each urd run by 0.1 points or less and ara by 4.2. We kept the strict scores.
  • Letters found in order is the longest common subsequence. Words: whole words right, in any order. Slips come from a second alignment, so counts are close, not exact.
  • Models from tessdata_fast, tessdata_best and tessdata at tag 4.1.0. tessdata's urd is the fast urd plus one config line: the same text on all 30 pages.
  • One thread a run, 3 runs at a time, at low priority, while other jobs ran. Times are rough.
  • OCRmyPDF 17.13.0, pdftotext from Poppler 26.03.0, PDFKit on macOS 26.6. The PDF holds one JPEG scan a page.
  • Licenses: Tesseract and tessdata are Apache-2.0, OCRmyPDF is MPL-2.0. Of the scan files, 5 are marked public domain and 2 marked CC BY-SA 4.0. We show no page images and quote no passage.

Scanned pages to text, no install

Run it yourself. Our Apify Actor turns a scanned PDF into Markdown or text. $0.006 a scanned page. It reads 18 languages, not Urdu.

Try the Actor

Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free. For Urdu, ask first.

Get one page free

Questions people ask

Does Tesseract support Urdu?

Yes, with urd or script/Arabic. On our 30 old scans, urd best with a Sauvola threshold read 36.7% of letters and 10.1% of words.

Which Tesseract model is best for Urdu?

On our pages, not upscaled, urd from tessdata_best with the Sauvola threshold (-c thresholding_method=2). It beat the fast urd by 5.0 points of letters and 1.3 points of words. Upscaling narrows the gap.

Can I use the Arabic model, ara, for Urdu?

Not well. ara lacks ی, ک, ہ, ے and 11 more Urdu letters: 35.6% of the letters on our pages. It got 1.4% of words right.

Can I OCR an Urdu PDF?

Yes. OCRmyPDF with -l urd and --tesseract-thresholding sauvola found 36.1% of letters and 9.9% of words on our 30-page PDF. Search the sidecar text file.

Is free Tesseract good enough for old Urdu books?

Not on our scans. About 1 word in 10 came out right, and a page from another book gets 7.7% of words by chance. Plan to check every line.