Skip to main content

Sokhanvar

A Python library for Persian text-to-speech with YAML configuration and an optional Gradio playground.

The included backend uses Pocket TTS Farsi v2. Other Persian TTS models can integrate through backend adapters.

Installation

Requires Python 3.12, 3.13, or 3.14.

uv add "sokhanvar[pocket] @ git+https://github.com/tavallaie/sokhanvar.git"

For development from this repository:

uv sync --extra pocket --extra playground

The pocket extra installs the speech runtime. The playground extra installs Gradio and is optional.

Usage

Save as sokhanvar.yaml:

backend: pocket_tts_farsi
model: mehdi-hf/pocket-tts-farsi-v2
language: fa
reference_audio: reference.wav
output_dir: outputs

Place your reference recording beside the YAML file, then generate speech:

from sokhanvar import Sokhanvar

speaker = Sokhanvar.from_yaml("sokhanvar.yaml")
result = speaker.synthesize("امروز هوا خوب است.", "speech.wav")

The result contains the WAV path, JSON metadata path, and generation metadata. Relative paths resolve beside the YAML file. Pocket Farsi uses up to five seconds of reference audio and downloads model weights on first use.

See the full configuration for pronunciation, pause, and sampling settings.

For CLI synthesis from the repository:

uv run --extra pocket sokhanvar synthesize \
  --config sokhanvar.yaml --text "امروز هوا خوب است." --output speech.wav

Playground

uv run --extra pocket --extra playground sokhanvar playground --config sokhanvar.yaml

Open localhost:7860 to compare A/B pronunciation and pauses. The playground exports YAML settings, edited phrase plans, and a ZIP containing the reference recording for use in another project.

License

The library uses Apache 2.0. Pocket TTS Farsi v2 weights use CC BY-NC 4.0. The Persian pronunciation model has separate license terms.

Metadata

Release files for sokhanvar 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sokhanvar 0.1.0
File Size Uploaded
sokhanvar-0.1.0.tar.gz 26.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sokhanvar 0.1.0
File Interpreter ABI Platform
sokhanvar-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 58.5 kB

Release files / sokhanvar-0.1.0.tar.gz

Download URL sokhanvar-0.1.0.tar.gz
Size 26.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6413659c59adf5eadb484e4d1a271335462c1538dbea5e2b288738761f4a8751
BLAKE2b-256 checksum
How to use checksums
41ec4c8b8153fdbbedd9eb6c38c516fa9fc1ba5ad0a1b2568f195c80ea3346f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sokhanvar-0.1.0-py3-none-any.whl

Download URL sokhanvar-0.1.0-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e565639da153533c0aba9bf94d9b684ee610df966dcdec1bae6938523e1f71b5
BLAKE2b-256 checksum
How to use checksums
ad34dba2142ecad1845eb50464d0082a9b0a40c1736369e273f3f0ae3f405cb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page