Metadata-Version: 2.4
Name: persian-speech
Version: 1.0.1
Summary: Natural Persian Text-to-Speech. One command.
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
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. One command.

## Install

```bash
pip install persian-speech
python -c "import urllib.request, os; os.makedirs('models', exist_ok=True); urllib.request.urlretrieve('https://huggingface.co/MahtaFetrat/Mana-Persian-Piper/resolve/main/fa_IR-mana-medium.onnx', 'models/fa_IR-mana-medium.onnx'); urllib.request.urlretrieve('https://huggingface.co/MahtaFetrat/Mana-Persian-Piper/resolve/main/fa_IR-mana-medium.onnx.json', 'models/fa_IR-mana-medium.onnx.json'); print('Done')"
```

## Usage

**Command line:**

```bash
speech "سلام به همگی" output.wav
```

**Python:**

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

**Server:**

```bash
python -c "from persian_speech_runtime import PiperSpeechEngine; from http.server import HTTPServer, BaseHTTPRequestHandler; from urllib.parse import urlparse, parse_qs; tts = PiperSpeechEngine(); exec('class H(BaseHTTPRequestHandler):\\n def do_GET(self):\\n  q = parse_qs(urlparse(self.path).query)\\n  t = q.get(\"text\",[\"سلام\"])[0]\\n  self.send_response(200)\\n  self.send_header(\"Content-Type\",\"audio/wav\")\\n  self.end_headers()\\n  self.wfile.write(tts.stream(t))'); HTTPServer(('0.0.0.0',8000), H).serve_forever()"
# http://localhost:8000/tts?text=سلام
```

## Model

Built on [Mana-Persian-Piper](https://huggingface.co/MahtaFetrat/Mana-Persian-Piper), trained on 114 hours of Persian speech from the [Mana-TTS](https://huggingface.co/datasets/MahtaFetrat/Mana-TTS) dataset.

## API

```python
from persian_speech_runtime import PiperSpeechEngine, talk

# One-liner
talk("سلام به همگی", "output.wav")

# Engine
tts = PiperSpeechEngine()
tts.save("سلام به همگی", "output.wav")   # Save to file
tts.stream("سلام به همگی")               # Get WAV bytes
tts.synthesize("سلام به همگی")           # Get numpy array
```

## License

MIT

