Metadata-Version: 2.4
Name: preling
Version: 1.5.1
Summary: Command-line tool for learning foreign languages through gradual exposure to new vocabulary
Home-page: https://github.com/danmysak/preling
Author: Danylo Mysak
Author-email: danmysak@gmail.com
Project-URL: Bug Tracker, https://github.com/danmysak/preling/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: google-cloud-texttospeech
Requires-Dist: openai[voice_helpers]
Requires-Dist: prompt_toolkit
Requires-Dist: pyaudio
Requires-Dist: spacy
Requires-Dist: SQLAlchemy
Requires-Dist: tqdm
Requires-Dist: typer
Provides-Extra: ja
Requires-Dist: spacy[ja]; extra == "ja"
Dynamic: license-file

# PreLing

PreLing is a command-line tool for improving language comprehension skills through gradual exposure to new vocabulary. It supports every language that [spaCy supports](https://spacy.io/usage/models#languages). Because PreLing uses GPT under the hood, you must have a paid [OpenAI account](https://platform.openai.com/) and an [API key](https://platform.openai.com/api-keys) to run it.

## Installation

Install [Python](https://www.python.org/downloads/) **3.12 or later** and [pipx](https://pipx.pypa.io/stable/installation/), then run:

```bash
pipx install preling          # install
pipx install "preling[ja]"    # alternatively: install with Japanese support
pipx upgrade preling          # upgrade
pipx uninstall preling        # uninstall (hopefully you won't need this)
```

## Initialize a New Language

Prepare a plain-text file that contains **one sentence per line** in the language you want to learn. For example, you can download a monolingual corpus from [OPUS](https://opus.nlpl.eu/). Then run:

```bash
preling init <lang> <corpus>
```

`<lang>` is the [language code](https://spacy.io/usage/models#languages), and `<corpus>` is the path to the corpus file.

## Study a Language

```bash
preling study <lang> [--audio] [--audio-only] [--model <GPT_MODEL>] \
               [--tts-model <TTS_MODEL>] [--api-key <OPENAI_KEY>] [--tts-api-key <OPENAI_OR_GCLOUD_KEY>]
```

* **`<lang>`** – the language code you initialized earlier.
* **`--audio`** – play audio along with the text.  
* **`--audio-only`** – play audio without displaying the text.  
* **`--tts-locale`** – the locale for text-to-speech (e.g., `en-US`, `ja-JP`); required for Gemini models.
* **`--model`** – the GPT model to use for grammar evaluation.  
* **`--tts-model`** – the text-to-speech model to use for audio playback.
* **`--api-key`** – your OpenAI API key.
* **`--tts-api-key`** – your OpenAI API key for text-to-speech, or path to Google Cloud service account JSON file for Gemini models.

Instead of passing these options each time, you can set the environment variables `PRELING_API_KEY`, `PRELING_MODEL`, `PRELING_TTS_API_KEY`, and `PRELING_TTS_MODEL`.

## View Your Progress

```bash
preling stats <lang>
```

## Other Commands

```bash
preling path <lang>               # show the path to the language data file
preling delete <lang> [--force]   # delete the language data file; use --force to skip the confirmation prompt
```
