Metadata-Version: 2.4
Name: negar-gui
Version: 1.5.10
Summary: Graphical User Interface for Negar -- Persian Text Editor
Author-email: Javad Razavian <javadr@gmail.com>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, http://github.com/javadr/negar-gui
Keywords: Spellcheck,Persian,Text-Editor
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-negar>=1.4.15
Requires-Dist: PyQt6
Requires-Dist: pyperclip
Requires-Dist: pyuca
Requires-Dist: redlines
Requires-Dist: regex
Requires-Dist: requests
Requires-Dist: qrcode
Requires-Dist: docopt
Requires-Dist: Image
Requires-Dist: pyqtdarktheme-fork
Requires-Dist: toml
Requires-Dist: duckdb
Requires-Dist: PyQt6-Charts
Requires-Dist: typing_extensions
Requires-Dist: rich
Provides-Extra: tts
Requires-Dist: torch; extra == "tts"
Requires-Dist: pocket-tts>=4.0.1; extra == "tts"
Provides-Extra: tts-hq
Requires-Dist: chatterbox-tts; extra == "tts-hq"
Requires-Dist: setuptools<81; extra == "tts-hq"
Dynamic: license-file

﻿Negar-GUI
==============
[![PyPI](https://img.shields.io/pypi/v/negar-gui?style=social)](https://pypi.org/project/negar-gui/)
[![code size](https://img.shields.io/github/languages/code-size/javadr/negar-gui?style=social)](https://github.com/javadr/negar-gui/archive/master.zip)
![GitHub language count](https://img.shields.io/github/languages/count/javadr/negar-gui?style=social)
![GitHub top language](https://img.shields.io/github/languages/top/javadr/negar-gui?style=social)
[![GitHub forks](https://img.shields.io/github/forks/javadr/negar-gui?style=social)](https://github.com/javadr/negar-gui/network/members)
[![GitHub license](https://img.shields.io/github/license/javadr/negar-gui?style=social)](https://github.com/javadr/negar-gui/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/javadr/negar-gui?style=social)](https://github.com/javadr/negar-gui/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/javadr/negar-gui?style=social)](https://github.com/javadr/negar-gui/issues)
[![Downloads](https://pepy.tech/badge/negar-gui)](https://pepy.tech/project/negar-gui)
[![Downloads](https://pepy.tech/badge/negar-gui/month)](https://pepy.tech/project/negar-gui)
![GitHub last commit](https://img.shields.io/github/last-commit/javadr/negar-gui)

Graphical User interface for `negar`


![Negar's English view](https://raw.github.com/javadr/negar-gui/master/images/negar-en.png)
![Negar's Persian view](https://raw.github.com/javadr/negar-gui/master/images/negar-fa.png)

Features
==============
- **Persian text cleanup** with live side-by-side or comparative (diff) view and configurable editing options.
- **Screen reader (OCR):** drag a rectangle over anything on screen, or use an image from the clipboard, and read its text into the editor (Persian, English and German). See [Screen reader](#screen-reader).
- **AI grammar fix:** send the text to an LLM (Gemini, Groq, OpenRouter, OpenAI, or free Pollinations) with your own prompts and a usage report. See [AI grammar fix](#ai-grammar-fix).
- **Read, fix, copy:** OCR a screenshot, clean it with Negar, and polish it with the AI button, all in one window.
- QR code of the result, interactive clipboard, Persian keyboard on startup, light/dark themes.

Installation
==============

## PyPi

**python-negar** is available on [PyPi](http://pypi.python.org/pypi/negar-gui):

    $ pip install negar-gui

## Git

You can retrieve the latest stable changes from the GitHub server:

    $ git clone https://github.com/javadr/negar-gui.git
    $ cd negar-gui
    $ python setup.py install

## Zip, Tarball

You can download the latest tarball.

### *nix

Get the latest tarball & install:

    $ wget -O negar-gui-master.tar.gz https://github.com/javadr/negar-gui/archive/master.tar.gz
    $ tar xvzf negar-gui-master.tar.gz && cd negar-gui-master
    $ python setup.py install

### Windows

Download the latest zip archive.

https://github.com/javadr/negar-gui/archive/master.zip

Decompress it, and run the following command in the root directory of `negar-gui`

    $ python setup.py install

#### Requirements
The GUI is relied on `python-negar` as well as `PyQt5/6`, `pyperclip`, `pyuca`, `redlines`, `regex`, `requests`, `qrcode`, `docopt`, `Image`, `pyqtdarktheme-fork`, and `toml`.
If you want to just run it by calling the script, you need to install its dependencies.

    $ pip install python-negar PyQt5 PyQt6 pyuca pyperclip redlines regex requests qrcode docopt Image pyqtdarktheme-fork toml

## Usage
Just use one of the following in your terminal.

    $ negar-gui

or simply

    $ negar

### Persian keyboard on startup
If a Persian keyboard layout is installed, Negar switches to it when it starts and switches back when it closes (turn it off in *Settings → Persian Keyboard on Startup*). This works on Windows, macOS, KDE Plasma, Sway and X11 desktops. GNOME has no built-in way for apps to change the layout, so there you need the [Shyriiwook](https://extensions.gnome.org/extension/6691/shyriiwook/) extension.

### Screen reader
*Edit → Read Text from Screen* (Ctrl+Shift+O) lets you drag a rectangle over anything on screen; the text is recognised with [Tesseract](https://github.com/tesseract-ocr/tesseract) and put into the input editor. *Edit → Read Text from Clipboard Image* (Ctrl+Alt+O) does the same for an image you copied (e.g. a screenshot). Pick the language in *Edit → OCR Language*: fewer languages are more accurate. Persian recognition is Tesseract's weak spot, so check the result; the AI button below can help fix recognition mistakes. Your language choice is remembered between runs.

*OCR → Run Prompt after OCR* binds one of your AI prompts to both OCR commands: after the text is read, that prompt runs on it automatically (for example to fix recognition mistakes) and the result lands in the output box. Choose *None* to just read the text. The choice is remembered, and the menu follows the GUI language.

The standalone executable includes Tesseract with English, Persian and German data. With a pip install you need your own: `pacman -S tesseract tesseract-data-fas tesseract-data-eng tesseract-data-deu`, or `apt install tesseract-ocr tesseract-ocr-fas tesseract-ocr-eng tesseract-ocr-deu`. On Wayland the screenshot is taken through the desktop's screenshot portal (GNOME and KDE have it; on other compositors install `xdg-desktop-portal-wlr`).

### Read aloud
*Speech → Read Aloud* (Ctrl+Shift+R, or the speaker button in the toolbar) reads the selection, or the whole text, of the box you last worked in, in Persian, offline. Each box also has its own speaker button in its top-left corner that reads just that box. Nothing is sent to a cloud, and the sentence being read is highlighted. While reading, the buttons turn into Stop; press again to stop.
It is optional and **only available with a pip install** (not in the standalone executable). Pick the voice in *Speech → Voice*; the choice is remembered:

| Voice | Install | Download | Notes |
|---|---|---|---|
| **Fast**: [Cilla Mini](https://huggingface.co/mehdi-hf/cilla-mini) (default) | `pip install --extra-index-url https://download.pytorch.org/whl/cpu torch "pocket-tts>=4.0.1"` or `pip install --extra-index-url https://download.pytorch.org/whl/cpu "negar-gui[tts]"` | about 112 MB | Runs on the CPU, loads in seconds, about 1 GB RAM. CC BY-NC 4.0. |
| **Balanced**: [Cilla Lite](https://huggingface.co/mehdi-hf/cilla-lite) | same packages as Fast | about 450 MB | Same engine as Fast (CPU), a bigger model. CC BY-NC 4.0. |
| **High quality**: [Chatterbox Farsi](https://huggingface.co/mehdi-hf/chatterbox-farsi) | `pip install chatterbox-tts "setuptools<81"` or `pip install "negar-gui[tts-hq]"` | about 3 GB | Better voice, but slow to load; wants an NVIDIA GPU (on the CPU it is much slower than real time). Non-commercial license; public use must display "Powered by OncillaAI Chatterbox Farsi"; output carries an inaudible watermark. |

Python 3.10+. Either model is gated: open its page and accept the terms, create a *Read* token at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens), then run `hf auth login --token <your token>`. The model downloads the first time you press Read Aloud, with a progress bar, and loads in the background when Negar starts. Only Persian letters are read: write English words and numbers in Persian.

### AI grammar fix
The AI button sends the input text (typed, pasted or read by the screen reader) to a language model and shows the model's answer in the output pane. Choose or edit the instruction in *Assistant → Manage Prompts...*, and see requests and success rate per provider and prompt in *Assistant → Usage Report...*.

The AI button works without setup through Pollinations, which is free but slow and rate-limited. For better results, open *Assistant → AI Provider...*, pick a provider and paste your own API key. [Google Gemini](https://aistudio.google.com/apikey), [Groq](https://console.groq.com/keys) and [OpenRouter](https://openrouter.ai/settings/keys) give free keys, and [OpenAI](https://platform.openai.com/api-keys) is paid. Keys are stored in plain text in the settings file (on Linux and macOS the file is made readable only by your user).

## Docker

A Docker image is available on [Docker Hub](https://hub.docker.com/r/javadr/negar-gui):

    $ docker pull javadr/negar-gui

Build it locally:

    $ make docker-build

### Run on X11

    $ docker run --rm \
        -e DISPLAY=$DISPLAY \
        -v /tmp/.X11-unix:/tmp/.X11-unix \
        -v $HOME/.config/negar-gui:/home/negar/.config/negar-gui \
        javadr/negar-gui

### Run on Wayland

    $ docker run --rm \
        -e QT_QPA_PLATFORM=wayland \
        -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
        -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
        -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY \
        --device /dev/dri \
        -v $HOME/.config/negar-gui:/home/negar/.config/negar-gui \
        javadr/negar-gui

### Auto-detect (via Makefile)

    $ make docker-run
