Part III — Branches, sap and seeds
07 · The sap: enrichment
Sap rises from the root to the leaves without anyone seeing it. Enrichment does the same with attachments: it pulls text out of PDFs, recognizes scanned pages, writes subtitles for speech — so that search can find things and people who can't hear can read.
Files to read
docs/baobaxia-enriquecimento.md— the complete design (read it first).enriquecimento/servico.py—Enriquecedor: decide, run, write.enriquecimento/procedencia.py— the record of "what was done to which file, by which engine, with which result" (data.enriquecimento).enriquecimento/classificar.py,textos.py,ocr.py,transcricao.py,legendas.py,vocabulario.py.infra/previa_video.py,infra/thumbnails.py,infra/mosaico.py.
What is automatic and what must be requested
| Automatic | Only on request (per file) | |
|---|---|---|
| Text from PDF, docx, odt, txt, html | ✅ (local cache) | |
| Video seek-bar preview | ✅ (local cache) | |
| Transcription with Whisper | data.transcrever: [files] | |
| OCR with Tesseract | data.ocr: [files] |
The request travels with sync: whoever asks can be a mucua without Whisper; the next mucua with the capability and the file does the work, and the subtitles return to everyone as an attachment (<file>.<language>.vtt, in the annex).
flowchart TD
A[attachment in content] --> B{is there already a provenance record<br/>with the same hash?}
B -- yes --> C{--forcar, or a better model here<br/>and output not reviewed by a person?}
C -- no --> Z[skip]
C -- yes --> D
B -- no --> D[classify]
D -->|audio/video| E{is it in data.transcrever?}
E -- no --> Z
E -- yes --> E2[ffmpeg 16 kHz → Whisper + VAD + vocabulary<br/>→ file.pt.vtt in the annex]
D -->|PDF| F[pdftotext → local cache]
F --> F2{pages without text?}
F2 -- yes, no request --> F3[status: precisa_ocr]
F2 -- yes, with data.ocr --> G[Tesseract → file.ocr.txt in the annex]
D -->|image| H{is it in data.ocr?}
H -- yes --> G
H -- no --> Z
D -->|docx/odt/txt/html| I[text → local cache]
The care the code takes
- Process lock (
_TravaProcesso): only one round per machine; another one answersja_em_andamento. - Galaxy lock: waits for sync and requests to let go (
ESPERA_TRAVA). - Clean interruption (
_SemInterrupcao): Ctrl-C in the middle of writing waits for the commit to finish, so the.bbxis never left half-written. - Human review wins:
foi_revisadacompares the recorded hash with that of the current subtitles. If someone corrected the subtitles, the machine does not write over them. - Limited attempts on error (
MAX_TENTATIVAS), and an environment error (missing engine) does not use up an attempt.
Practice
- Read
test_enriquecimento_whisper.py::test_transcricao_so_dos_arquivos_marcadosand explain why not every video gets transcribed. - With
ffmpeginstalled, make a short video, publish it, mark it indata.transcreverand runbbx enriquecer --saber <uuid>. Where do the subtitles appear on disk? And in the index? - In
procedencia.py, followprecisa_processar. In which case does a larger model redo the subtitles? - Add place names from your community to a saber's vocabulary (
data.vocabulario) and compare the transcription.
To talk about
- Machine-made subtitles in an Indigenous language or a quilombola way of speaking get things wrong. How does the system's design make room for corrections made by the community?
