gandr-haystack
Gandr text to speech as a Haystack component.
Install
pip install gandr-haystack
Use
import os
from gandr_haystack import GandrTTS
tts = GandrTTS(voice="gandr-mia") # reads GANDR_API_KEY from the env
result = tts.run(text="Your appointment is confirmed for Tuesday at two fifteen.",
path="out.wav")
result["audio"] # WAV bytes
In a pipeline:
from haystack import Pipeline
pipe = Pipeline()
pipe.add_component("tts", GandrTTS())
pipe.run({"tts": {"text": "Hello from Haystack."}})
Parameters
| Parameter | Default | Notes |
|---|---|---|
api_key |
Secret.from_env_var("GANDR_API_KEY") |
Keys start with gnd_ |
voice |
gandr-mia |
Also gandr-ava, gandr-jenny, gandr-dane, gandr-leo, gandr-lewis |
language |
en |
ISO code |
sample_rate |
24000 |
One of 8000, 16000, 22050, 24000 |
url |
https://tts.gandr.ai/v1/tts/bytes |
Override to pin a region |
timeout |
60.0 |
Seconds |
run() returns {"audio": bytes, "path": str | None}. Pass path to write the
WAV to disk as well as returning it.
The component serializes with to_dict() and from_dict(), and the key is held
as a Haystack Secret read from the environment, so saved pipelines never carry
the token.
Loading a saved pipeline
Haystack will not deserialize a third-party component unless its module is allowlisted. That is Haystack's security model, not a quirk of this package, and it applies to every community integration:
from haystack.core.serialization import allow_deserialization_module
allow_deserialization_module("gandr_haystack.tts")
Or set HAYSTACK_DESERIALIZATION_ALLOWLIST=gandr_haystack.tts in the environment.
Saving with to_dict() needs nothing.
Errors
An HTTP failure raises RuntimeError carrying the API's own status and message,
so a 401 (key) and a 402 (quota) are told apart rather than guessed at.
Pricing
$10 per million characters, or $150 a month for one unlimited concurrent stream. Free key, 100,000 characters, no card: gandr.ai
License
MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gandr_haystack-0.1.0.tar.gz.
File metadata
- Download URL: gandr_haystack-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eddb0c718281ba75146e009e808670b65fe581449e74e46e197b7562bc4bc8a6
|
|
| MD5 |
74bbe2c5a725a0d3b9eabb5f2a536c67
|
|
| BLAKE2b-256 |
513133304f28658c9590ebbbd212f30f26ecf06f2f6d6b7443e36ce8043baf11
|
File details
Details for the file gandr_haystack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gandr_haystack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a64931336d4a9a563a2d94db4e725091bc4c79fa2806c3a7ed16fdc8debf631d
|
|
| MD5 |
089cb098a2fc4cc8d8597f1d19e561b2
|
|
| BLAKE2b-256 |
c98044d74aef54afadfd8b553a6940574cbe87ca34076829dd558308573b353b
|