{"id":22161691,"url":"https://github.com/gauff/textprocessing","last_synced_at":"2025-03-24T15:26:05.647Z","repository":{"id":248263095,"uuid":"817683590","full_name":"Gauff/TextProcessing","owner":"Gauff","description":"Text extraction, transcription, punctuation restoration, translation, summarization and text to speech from almost any file type","archived":false,"fork":false,"pushed_at":"2024-11-05T09:28:18.000Z","size":98,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T20:40:19.170Z","etag":null,"topics":["cli","file-downloader","llm","ocr","punctuation-restoration","python","summarizer","text-extraction","text-extraction-from-image","text-processing","text-to-speech","transcoding","transcription","translator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gauff.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-20T08:22:09.000Z","updated_at":"2024-11-05T09:28:21.000Z","dependencies_parsed_at":"2025-01-29T20:33:21.650Z","dependency_job_id":"cda584bd-63d4-4f60-bf63-fdce15340cb0","html_url":"https://github.com/Gauff/TextProcessing","commit_stats":null,"previous_names":["gauff/textprocessing"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gauff%2FTextProcessing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gauff%2FTextProcessing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gauff%2FTextProcessing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gauff%2FTextProcessing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gauff","download_url":"https://codeload.github.com/Gauff/TextProcessing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245296365,"owners_count":20592202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","file-downloader","llm","ocr","punctuation-restoration","python","summarizer","text-extraction","text-extraction-from-image","text-processing","text-to-speech","transcoding","transcription","translator"],"created_at":"2024-12-02T04:16:32.860Z","updated_at":"2025-03-24T15:26:05.613Z","avatar_url":"https://github.com/Gauff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Icon](https://github.com/Gauff/TextProcessing/blob/master/tp_icon.png)\r\n\r\n# Project Overview\r\n\r\n**TLDR; Text extraction, transcription, punctuation restoration, translation, summarization and text to speech**\r\n\r\nThe goal of this project is to extend the functionalities of [Fabric](https://github.com/danielmiessler/fabric). I'm particularly interested in building pipelines using utilities like `yt` as a source and chaining them with the `|` operator in CI.\r\n\r\nHowever, a major limitation exists: all operations are constrained by the LLM context. For extracting information from books, lengthy documents, or long video transcripts, content may get truncated.\r\n\r\nTo address this, I started working on adding a summarization step before applying a `fabric` template, based on the document length. \r\nAdditionally, I explored capabilities like transcripting, translating and listening to the pipeline result or saving it as an audio file for later consumption.\r\n\r\n## Examples\r\n\r\n### Listen to the condensed summary of a long Youtube video\r\n`yt --transcript url | tp --cb | tts`\r\n\r\n### Read a web page summary\r\n`tp --ebullets https://en.wikipedia.org/wiki/Text_processing`\r\n\r\n### Listen to the condensed French summary of a long English Youtube video\r\n`yt --transcript --lang en url | tp --cb --tr fr | tts`\r\n\r\n### Save a book's wisdom as an audio file\r\n`tp my_book.txt --eb | fabric --p extract_wisdom | tts --o my_book_wisdom.mp3` \r\n\r\n### Say \"hello world!\" in Chinese\r\n`echo \"Hello world!\" | tp --tr zh | tts`\r\n\r\n### Translate a document to Spanish\r\n`tp doc_fr.txt --tr es \u003e doc_es.txt`\r\n\r\n### Generate a transcript in any language from a mp4 file. E.G.: from English to French\r\n`tp en.mp4 --tr fr`\r\n\r\n### Listen in spanish a French audio file\r\n`tp fr.mp3 --tr es | tts` \r\n\r\n### Convert a spanish audio book to a French audio book... and make an English transcript\r\n`tp es.mp3 --tr fr | tts --o fr.mp3 | tp fr.mp3 --tr en --o tr_en.txt`\r\n\r\n### Extract ideas from an audio file, save them in a French text file\r\n`tp en.mp3 | fabric --p extract_ideas | tp --tr fr --o idées.txt`\r\n\r\n### Perform OCR\r\n`tp image.png` \r\n\r\n### Extracts text from a Word file\r\n`tp document.docx` \r\n\r\n# Text Processing (`tp`)\r\n\r\n## Input (text or audio file)\r\n\r\n`tp` receives from `stdin` or as first command line argument\r\nIt accepts:\r\n- Text.\r\n- File path. Supported formats are: .aiff, .bmp, .cs, .csv, .doc, .docx, .eml, .epub, .flac, .gif, .htm, .html, .jpeg, .jpg, .json, .log, .md, .mkv, .mobi, .mp3, .mp4, .msg, .odt, .ogg, .pdf, .png, .pptx, .ps, .psv, .py, .rtf, .sql, .tff, .tif, .tiff, .tsv, .txt, .wav, .xls, .xlsx\r\n\r\n`tp` accepts unformatted content, such as automatically generated YouTube transcripts. If the text lacks punctuation, it restores it before further processing, which is necessary for chunking and text-to-speech operations.\r\n\r\n## Transcription\r\n\r\nConverts audio and video files to text using Whisper.\r\n\r\n## Summarization\r\n\r\nThe primary aim is to summarize books, large documents, or long video transcripts using an LLM with an 8K context size. Various summarization levels are available:\r\n\r\n### Extended Bullet Summary (`--ebullets`, `--eb` )\r\n\r\n- Splits text into chunks.\r\n- Summarizes all chunks as bullet points.\r\n- Concatenates all bullet summaries.\r\n\r\nThe goal is to retain as much information as possible.\r\n\r\n### Condensed Bullet Summary (`--cbullets`, `--cb`)\r\n\r\nExecutes as many `extended bullet summary` phases as needed to end up with a bullet summary smaller than an LLM context size.\r\n\r\n### Textual Summary (`--text`, `--t`)\r\n\r\nA simple summarization that does not rely on bullet points.\r\n\r\n## Translation (`--translate`, `--tr`)\r\n\r\nTranslates the output text to the desired language.\r\nUse two letters code such as `en` or `fr`.\r\n\r\n## Usage\r\n```\r\nusage: tp [-h] [--ebullets] [--cbullets] [--text] [--lang LANG] [--translate TRANSLATE] [--output_text_file_path OUTPUT_TEXT_FILE_PATH] [text_or_path]\r\n\r\ntp (text processing) provides transcription, punctuation restoration, translation and summarization from stdin, text, url, or file path. Supported file formats are: .aiff, .bmp, .cs, .csv, .doc, .docx, .eml, .epub, .flac, .gif, .htm, .html, .jpeg, .jpg, .json, .log, .md, .mkv, .mobi, .mp3, .mp4, .msg, .odt, .ogg, .pdf, .png, .pptx, .ps, .psv, .py, .rtf, .sql, .tff, .tif, .tiff, .tsv, .txt, .wav, .xls, .xlsx\r\n\r\npositional arguments:\r\n  text_or_path          plain text; file path; file url\r\n\r\noptions:\r\n  -h, --help            show this help message and exit\r\n  --ebullets, --eb      Output an extended bullet summary\r\n  --cbullets, --cb      Output a condensed bullet summary\r\n  --text, --t           Output a textual summary\r\n  --lang LANG, --l LANG\r\n                        Forced processing language. Disables the automatic detection.\r\n  --translate TRANSLATE, --tr TRANSLATE\r\n                        Language to translate to\r\n  --output_text_file_path OUTPUT_TEXT_FILE_PATH, --o OUTPUT_TEXT_FILE_PATH\r\n                        output text file path\r\n```\r\n\r\n# Text To Speech (`tts`)\r\n\r\nListen to the pipeline result or save it as an audio file to listen later.\r\n\r\n`tts` can also read text files, automatically detecting their language.\r\n\r\n```\r\nusage: tts.py [-h] [--output_file_path OUTPUT_FILE_PATH] [--lang LANG] [input_text_or_path]\r\n\r\ntts (text to speech) reads text aloud or to mp3 file\r\n\r\npositional arguments:\r\n  input_text_or_path    Text to read or path of the text file to read.\r\n\r\noptions:\r\n  -h, --help            show this help message and exit\r\n  --output_file_path OUTPUT_FILE_PATH, --o OUTPUT_FILE_PATH\r\n                        Output file path. If none, read aloud.\r\n  --lang LANG, --l LANG\r\n                        Forced language. Uses language detection if not provided.\r\n```\r\n\r\n# Environment setup\r\n\r\n## `.env` file\r\n```\r\nGROQ_API_KEY=gsk_\r\nLITE_LLM_URI='http://localhost:4000/'\r\nSMALL_CONTEXT_MODEL_NAME=\"groq/llama3-8b-8192\"\r\nSMALL_CONTEXT_MAX_TOKENS=8192\r\n```\r\n\r\n## script short hand\r\n\r\n- Make script executable\r\n`chmod +x tts.py`\r\n\r\n- Create symlink : Link the script to a directory that's in your PATH\r\n`sudo ln -s tts.py /usr/local/bin/tts`\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgauff%2Ftextprocessing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgauff%2Ftextprocessing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgauff%2Ftextprocessing/lists"}