Tesseract and Spanish: eng gets 1 accent in 8 right
95%
of accents right with -l spa
One flag: 12.9% to 95.0%
Proofread pages from 13 Spanish books, printed 1902 to 1931:
| Model | Accents right | Words right |
|---|---|---|
-l eng, the default |
12.9% | 84.9% |
-l spa |
95.0% | 96.3% |
98.1% of letters right with eng, accents aside
15.1% of words wrong with eng
eng reads the letters. It drops almost every mark, and it often turns ó into é.
What eng does to Spanish words
Real words from these scans. Each time, spa read it right:
| Printed | eng read | Times |
|---|---|---|
| más | mas | 37 |
| á | a | 26 |
| está | esta | 14 |
| país | pais | 10 |
| doña | dofia | 9 |
más became mas on 16 of 26 pages, so "more" turns into "but". And eng kept 0 of the 48 ¿ and ¡ marks. spa kept all 48.
Install spa, then pass -l spa
-
Debian or Ubuntu:
sudo apt install tesseract-ocr-spa -
macOS:
brew install tesseract-lang, all languages - Check:
tesseract --list-langsshows spa
This writes page.txt:
tesseract page.png page -l spa
In Python:
import pytesseract
print(pytesseract.image_to_string("page.png", lang="spa"))
Bigger models and mixes lose accents
Each against plain spa, which took 1.0 seconds a page:
| Setting | Accents right | Sec a page |
|---|---|---|
| spa from tessdata_best | 93.8% | 2.2 |
-l spa+eng |
90.5% | 1.3 |
-l eng+spa |
90.4% | 1.3 |
| script/Latin, for all Latin-alphabet languages | 85.7% | 1.6 |
Adding eng cost 55 or 56 accents, in either order. Use spa alone on Spanish pages.
How I tested it
- Pages: es.wikisource scans whose text was proofread (level 3) or also checked by a second person (level 4). Books picked by a seeded shuffle, not by me, 2 pages a book. Pages with notes, poems or tables were skipped.
- Books printed 1900 to 1950 only. Older print often has no accent where the wiki text has one (nacion, nación).
- A page also had to match its scan: Tesseract had to find 80% of its letters. 30 pages failed, most of them Latin scans with a Spanish translation.
- 26 pages, 47,930 letters, 1,234 of them with an accent (or ñ, ü).
- Each scan is the wiki's page image: 18 at 1,920 px, 6 at 1,280 px, 2 at 960 px.
- Accents right: accented letters read right, in order. Words right: proofread words read right, accents and all, in order.
- Running heads and page numbers are not in the proofread text, so extra text costs nothing.
- spa+eng and eng+spa gave different text on 4 of 26 pages, but almost the same score.
- Tesseract 5.5.4, one thread. Models from tessdata_fast 4.1.0, the files Homebrew installs, and tessdata_best 4.1.0.
Our Actor: set Language to Spanish
Our Apify Actor reads scans with the same spa file. Its Language input starts at English. On these 26 scans, live build 0.1.44:
12.8% of accents right, left at English
92.9% set to Spanish
Test build 0.1.52 read these pages the same way. It is not the live build yet.
What I did not test
- Phone photos, faxes, and scans under 960 px wide.
- Books printed before 1900, and the spa_old model.
- Handwriting. See this test.
- Other languages. French and Portuguese have their own tests.
- Windows and Linux. One Mac.
Sources
Two ways to skip the work
Run it yourself. Our Apify Actor turns scanned PDFs into Markdown, tables included.
Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free.
Questions people ask
Does Tesseract read Spanish?
Yes, with the spa model. On 26 proofread book scans it read 95.0% of accented letters right. The default eng read 12.9%.
Why does Tesseract drop Spanish accents?
Usually it runs with eng, the default. On these scans eng read í as i 264 times and ó as é 184 times. Pass -l spa.
Is spa from tessdata_best worth it?
Not on these scans. It read 93.8% of accents right, under plain spa, and it took 2.2 seconds a page.