Metadata-Version: 2.4
Name: persian-speech
Version: 1.1.3
Summary: Natural Persian Text-to-Speech. One command.
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: piper-tts>=1.4.0
Requires-Dist: numpy

# Persian Speech 🎙️

Natural Persian Text-to-Speech. **Zero config, one command.**

> Built on Mana-Persian-Piper, trained on 114 hours of high-quality Persian speech.  
> Runs on servers, laptops, Raspberry Pi, and mobile devices. Entirely offline.

## Why Persian Speech?

- **Natural voice** — Trained on the largest Persian speech dataset (Mana-TTS)
- **Runs anywhere** — Linux, Windows, macOS, Raspberry Pi, Android, iOS
- **Edge & mobile ready** — ONNX runtime, lightweight model, no GPU needed
- **Offline first** — No internet after initial model download
- **Blazing fast** — 25x faster than realtime on CPU
- **One command** — `speech "سلام"` and you're done

## Install

```bash
pip install persian-speech
```

Model downloads automatically on first use. That's it.

## Usage

**Command line:**

```bash
speech "سلام به همگی"
speech "سلام دنیا" hello.wav
```

**Python:**

```python
from persian_speech_runtime import talk
talk("سلام به همگی", "output.wav")
```

**Server:**

```python
import sys

sys.path.insert(0, "src")
from persian_speech_runtime import PiperSpeechEngine
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs

tts = PiperSpeechEngine()


class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        q = parse_qs(urlparse(self.path).query)
        text = q.get("text", ["سلام به گل های توی خونه"])[0]
        self.send_response(200)
        self.send_header("Content-Type", "audio/wav")
        self.end_headers()
        self.wfile.write(tts.stream(text))


print("http://localhost:8000")
HTTPServer(("0.0.0.0", 8000), Handler).serve_forever()
```

## API

```python
from persian_speech_runtime import PiperSpeechEngine, talk

talk("سلام", "out.wav")              # One-liner

tts = PiperSpeechEngine()
tts.save("سلام", "out.wav")          # Save WAV
tts.stream("سلام")                   # WAV bytes
tts.synthesize("سلام")               # NumPy array
```

## License

MIT — Use it anywhere. Built on [Mana-Persian-Piper](https://huggingface.co/MahtaFetrat/Mana-Persian-Piper) (MIT) and [Mana-TTS](https://huggingface.co/datasets/MahtaFetrat/Mana-TTS) (CC0).
