https://github.com/sepandhaghighi/typio
Typio: Make Your Terminal Type Like a Human
https://github.com/sepandhaghighi/typio
cli console python python3 terminal typewriter typing ux
Last synced: 4 months ago
JSON representation
Typio: Make Your Terminal Type Like a Human
- Host: GitHub
- URL: https://github.com/sepandhaghighi/typio
- Owner: sepandhaghighi
- License: mit
- Created: 2026-01-05T10:41:44.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-02-18T03:13:23.000Z (4 months ago)
- Last Synced: 2026-02-18T07:57:19.614Z (4 months ago)
- Topics: cli, console, python, python3, terminal, typewriter, typing, ux
- Language: Python
- Homepage:
- Size: 268 KB
- Stars: 10
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: SECURITY.md
- Authors: AUTHORS.md
Awesome Lists containing this project
README
## Overview
Typio is a lightweight Python library that prints text to the terminal as if it were being typed by a human. It supports multiple typing modes (character, word, line, sentence, typewriter, and adaptive), configurable delays and jitter for natural variation, and seamless integration with existing code via a simple function or a decorator. Typio is designed to be minimal, extensible, and safe, making it ideal for demos, CLIs, tutorials, and storytelling in the terminal.
Branch
main
dev
CI
## Installation
### Source Code
- Download [Version 0.4](https://github.com/sepandhaghighi/typio/archive/v0.4.zip) or [Latest Source](https://github.com/sepandhaghighi/typio/archive/dev.zip)
- `pip install .`
### PyPI
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
- `pip install typio==0.4`
## Usage
### Function
Use `type_print` function to print text with human-like typing effects. You can control the typing speed, randomness, mode, and output stream.
#### Example
```python
from typio import type_print
from typio import TypeMode
type_print("Hello, world!")
type_print(
"Typing with style and personality.",
delay=0.06,
jitter=0.02,
end="\n",
mode=TypeMode.ADAPTIVE,
)
```
You can also redirect the output to any file-like object:
```python
with open("output.txt", "w") as file:
type_print("Saved with typing effects.", file=file)
```
#### Parameters
| Name | Type | Description | Default |
|------|------|-------------|---------|
| `text` | `str` | Text to be printed | -- |
| `delay` | `float` | Base delay (seconds) between emitted units | `0.04` |
| `jitter` | `float` | Random delay variation (seconds) | `0` |
| `end` | `str` | Ending character(s) | `\n` |
| `mode` | `TypeMode \| Callable` | Typing mode (built-in or custom) | `TypeMode.CHAR` |
| `file` | `TextIOBase` | Output stream | `sys.stdout` |
#### Built-in Modes
| Mode | Description |
|------|-------------|
| `TypeMode.CHAR` | Emit text **character by character** |
| `TypeMode.WORD` | Emit text **word by word**, preserving whitespace |
| `TypeMode.LINE` | Emit text **line by line** |
| `TypeMode.SENTENCE` | Emit text character by character with **longer pauses after `.`, `!`, `?`** |
| `TypeMode.TYPEWRITER` | Emit text character by character with **longer pauses after newlines** |
| `TypeMode.ADAPTIVE` | Emit text with **adaptive delays** based on character type (spaces, punctuation, alphanumeric) |
### Decorator
Use the `@typestyle` decorator to apply typing effects to all `print` calls inside a function, without changing the function's implementation.
#### Example
```python
from typio import typestyle
from typio import TypeMode
@typestyle(delay=0.05, mode=TypeMode.TYPEWRITER)
def intro():
print("Welcome to Typio.")
print("Every print is typed.")
intro()
```
#### Parameters
| Name | Type | Description | Default |
|------|------|-------------|---------|
| `delay` | `float` | Base delay (seconds) between emitted units | `0.04` |
| `jitter` | `float` | Random delay variation (seconds) | `0` |
| `mode` | `TypeMode \| Callable` | Typing mode (built-in or custom) | `TypeMode.CHAR` |
### Custom Mode
Typio also allows defining custom typing modes.
A custom mode is a callable that receives a typing context and the text being printed.
#### Example
This custom mode, named `dramatic`, adds exaggerated pauses after punctuation to create a dramatic typing effect.
```python
from typio import TypioContext
def dramatic(ctx: TypioContext, text: str):
for ch in text:
ctx.emit(ch)
if ch in ".!?":
ctx.sleep(delay=ctx.delay * 6)
```
Usage with `type_print` function:
```python
type_print(
"Wait... what?!",
mode=dramatic,
delay=0.05,
jitter=0.02,
)
```
Usage with `@typestyle` decorator:
```python
@typestyle(delay=0.06, mode=dramatic)
def demo():
print("This is serious.")
print("Very serious!")
demo()
```
#### Parameters
This table describes the `TypioContext` API, which is the interface exposed to custom typing modes for emitting text, controlling timing, and accessing delay settings.
| Name | Type | Description |
|------|------|-------------|
| `emit(text)` | `method` | Emit a text fragment using typing effects |
| `sleep(delay=None, jitter=None)` | `method` | Pause execution with optional delay and jitter override |
| `flush()` | `method` | Flush the underlying output stream |
| `delay` | `property` | Base delay in seconds |
| `jitter` | `property` | Jitter value in seconds |
### CLI
Typio provides a simple command line interface for printing text with typing effects.
#### Example
```console
> typio --text="Hello world!" --mode=typewriter --delay=0.03
```
## Issues & Bug Reports
Just fill an issue and describe it. We'll check it ASAP!
- Please complete the issue template
## Show Your Support
Star This Repo
Give a ⭐️ if this project helped you!
Donate to Our Project
Bitcoin
1KtNLEEeUbTEK9PdN6Ya3ZAKXaqoKUuxCy
Ethereum
0xcD4Db18B6664A9662123D4307B074aE968535388
Litecoin
Ldnz5gMcEeV8BAdsyf8FstWDC6uyYR6pgZ
Doge
DDUnKpFQbBqLpFVZ9DfuVysBdr249HxVDh
Tron
TCZxzPZLcJHr2qR3uPUB1tXB6L3FDSSAx7
Ripple
rN7ZuRG7HDGHR5nof8nu5LrsbmSB61V1qq
Binance Coin
bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qef
Tether
0xcD4Db18B6664A9662123D4307B074aE968535388
Dash
Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3s
Stellar
GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL
Zilliqa
zil1knmz8zj88cf0exr2ry7nav9elehxfcgqu3c5e5
Coffeete