⚡ One-liner AI utilities for text, images, and data.
This repository contains short, practical AI scripts built on Hugging Face Transformers 🤗 and PyTorch 🔥.
The goal is simple: provide ready-to-use AI commands that require minimal setup and deliver instant results.
- ✨ Features
- 📝 Text Summarization — Quickly condense long text into concise summaries.
- 😊 Sentiment Analysis — Detect positive, negative, or neutral sentiment in text.
- 🖼️ Image Captioning — Generate captions for images automatically.
- 🌐 Translator — Translate text from one language to another.
- 🔍 Named Entity Recognition — Extracts real-world entities like names, places, and organizations from text.
- 🔄 Paraphraser — Rewrites text with the same meaning in different words.
- 🌍 Language Detection — Detects the language of the given text instantly.
- 🔑 Keyword Extraction – Find Key Terms in Text
- 🔊 Text to Speech (TTS) – Convert any text into natural-sounding spoken audio (MP3/WAV).
- ❓ Question Answering (QA) - Ask a question about a given context and get precise answers extracted from the text.
- 🛠 Requirements
- 📥 Installation
▶️ Running the Project
Condenses long text into a shorter version while preserving the key meaning and context.
Example:
pyai summary "Artificial Intelligence is transforming industries..."Output:
Artificial Intelligence is transforming industries. Here are some of the ways it's changing the way we work. Read more at CNN.com/AI.Identifies the emotional tone of text, classifying it as POSITIVE, NEGATIVE, or NEUTRAL.
Example:
pyai sentiment "I like this new AI Tool"Output:
{'label': 'POSITIVE', 'score': 0.9992}Example:
pyai sentiment "Oh.. This looks so terrible.."Output:
{'label': 'NEGATIVE', 'score': 0.9997}Generates a concise, descriptive caption for an image — ideal for accessibility, tagging, and creative applications.
Example:
pyai caption "<path_to_the_image>"Output:
Automatically generates a relevant caption for the provided image.Effortlessly translates text from a source language to a target language — fast, accurate, and natural-sounding.
Example:
pyai translate "Hello. This is an example of AI translator command" --src en --tgt spOutput:
Bonjour. C'est un exemple de commande de traducteur AIIdentifies and classifies entities in text such as people, organizations, locations, dates, and more, using a pre-trained Transformer model.
Example:
pyai ner "Python was created by Guido van Rossum in 1991 and is maintained by the Python Software Foundation in the U
nited States." --aggregation-strategy simpleOutput:
| Entity | Label | Confidence |
|---|---|---|
| Python | MISC | 0.933 |
| Guido van Rossum | PER | 0.997 |
| Python Software Foundation | ORG | 0.999 |
| United States | LOC | 0.999 |
Generates alternative versions of your text while preserving its original meaning — ideal for improving clarity, variety, or tone.
Example:
pyai paraphrase "Artificial Intelligence is transforming industries." --num 3Output:
['Artificial Intelligence is changing industries.', 'Artificial Intelligence is changing the world.', 'Artificial intelligence is helping industries.']The Language Detector tool analyzes your input text and identifies its language with high accuracy. It’s useful for routing multilingual content, preprocessing text for translation, or simply detecting what language a piece of text is written in.
Example:
pyai detectlang "La inteligencia artificial está revolucionando la forma en que trabajamos y vivimos."Output:
{'language': 'es', 'score': 0.984924852848053}Automatically extract the most important words and phrases from any text using transformer-based NLP models. This helps in summarization, topic discovery, and quick content insights without reading the entire text.
Example:
pyai keywords "Artificial Intelligence is transforming industries through automation and data-driven decision making." \
--topk 8 --ngmin 1 --ngmax 2 --method mmr --diversity 0.6Output:
| Keyword | Score |
|---|---|
| industries automation | 0.701 |
| automation data | 0.588 |
| artificial intelligence | 0.548 |
| transforming industries | 0.453 |
| driven decision | 0.438 |
| intelligence transforming | 0.388 |
| data | 0.289 |
| making | 0.128 |
Convert written text into natural-sounding speech with Hugging Face’s multilingual TTS models.
This script generates audio files (MP3/WAV) from any input text.
Example:
pyai tts "Hello, welcome to my AI-PyShorts Repo" --lang en --out pyai_shorts/audio/sample_output/sample_audio.wavOutput:
pyai_shorts/audio/sample_output/sample_audio.wavAsk questions against a given context paragraph and get precise answers extracted from it.
Example:
pyai qa --context "Artificial Intelligence is changing healthcare and finance." --question "Which industries are being transformed by AI?"Output:
healthcare and finance- Python 3.11
- See requirements.txt for all dependencies.
- Clone the repository
git clone <repo-url>
cd AI-PyShorts- Create & activate a virtual environment
python3.11 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate - Install dependencies
pip install -r requirements.txt - Install the package in editable mode
pip install -e . Once installed, you can run the CLI directly:
pyai summary "Your text here..."Or run through Python:
python -m pyai_shorts.cli summary "Your text here..."