Skip to content

Refactor language handling and fix Tesseract OCR integration#8

Merged
louis030195 merged 2 commits intoscreenpipe:mainfrom
divanshu-go:tess-not-working
Oct 17, 2025
Merged

Refactor language handling and fix Tesseract OCR integration#8
louis030195 merged 2 commits intoscreenpipe:mainfrom
divanshu-go:tess-not-working

Conversation

@divanshu-go
Copy link
Contributor

  • Introduce macro-based Language enum with ISO and Tesseract codes

  • Replaces old enum + TESSERACT_LANGUAGES array

  • Compile-time mapping ensures type safety

  • Supports optional Tesseract codes for unsupported languages

  • Build language string in O(n) instead of nested searches

  • Eliminates brittle string matching and formatting

Before

image

After

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it failed:

  • Language::English (enum variant) was being compared to "english" (string)
  • The PartialEq<&str> implementation used the Display trait, which returns ISO codes like "en" (not "english")
  • So Language::English == "english" compared "en" == "english" → always false
  • When languages were specified, the filter returned empty results (no matches found)
  • Tesseract got called with -l (empty language parameter)
  • Tesseract segfaulted when given an invalid language argument

Now when you specify languages, Tesseract gets proper language codes like -l eng+fra+deu instead of crashing with -l . The macro system ensures type-safe, compile-time guaranteed language mappings with no runtime string operations.

@divanshu-go
Copy link
Contributor Author

divanshu-go commented Oct 17, 2025

@louis030195

image

@louis030195
Copy link
Contributor

awesome

@louis030195 louis030195 merged commit d142d2b into screenpipe:main Oct 17, 2025
0 of 3 checks passed
@divanshu-go
Copy link
Contributor Author

@louis030195 any tip on this one.

@louis030195
Copy link
Contributor

we don't use OCR, nor linux, so it's not very useful to us @divanshu-go

@divanshu-go
Copy link
Contributor Author

no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants