|
| 1 | +--- |
| 2 | +layout: integration |
| 3 | +name: Gandr |
| 4 | +description: Gandr Text-to-Speech component for Haystack. |
| 5 | +authors: |
| 6 | + - name: Gandr |
| 7 | + socials: |
| 8 | + github: Gandr-AI |
| 9 | +pypi: https://pypi.org/project/gandr-haystack/ |
| 10 | +repo: https://github.com/Gandr-AI/gandr-haystack |
| 11 | +type: Model Provider |
| 12 | +report_issue: https://github.com/Gandr-AI/gandr-haystack/issues |
| 13 | +logo: /logos/gandr.png |
| 14 | +version: Haystack 2.0 |
| 15 | +toc: true |
| 16 | +--- |
| 17 | + |
| 18 | +### **Table of Contents** |
| 19 | +- [Overview](#overview) |
| 20 | +- [Installation](#installation) |
| 21 | +- [Usage](#usage) |
| 22 | +- [Parameters](#parameters) |
| 23 | +- [Loading a saved pipeline](#loading-a-saved-pipeline) |
| 24 | +- [License](#license) |
| 25 | + |
| 26 | +## Overview |
| 27 | + |
| 28 | +[Gandr](https://gandr.ai) is a text-to-speech API. This integration adds a |
| 29 | +`GandrTTS` component that turns text into WAV audio inside a Haystack pipeline, |
| 30 | +and optionally writes it to disk. |
| 31 | + |
| 32 | +Six stock voices, output at 8 kHz to 24 kHz, and every render is watermarked. |
| 33 | + |
| 34 | +## Installation |
| 35 | + |
| 36 | +```bash |
| 37 | +pip install gandr-haystack |
| 38 | +``` |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +Set `GANDR_API_KEY` in your environment. Keys start with `gnd_`, and a free key |
| 43 | +with 100,000 characters is available at [gandr.ai](https://gandr.ai) without a |
| 44 | +card. |
| 45 | + |
| 46 | +```python |
| 47 | +from gandr_haystack import GandrTTS |
| 48 | + |
| 49 | +tts = GandrTTS(voice="gandr-mia") |
| 50 | +result = tts.run(text="Your appointment is confirmed for Tuesday at two fifteen.", |
| 51 | + path="out.wav") |
| 52 | +result["audio"] # WAV bytes |
| 53 | +``` |
| 54 | + |
| 55 | +In a pipeline: |
| 56 | + |
| 57 | +```python |
| 58 | +from haystack import Pipeline |
| 59 | +from gandr_haystack import GandrTTS |
| 60 | + |
| 61 | +pipe = Pipeline() |
| 62 | +pipe.add_component("tts", GandrTTS()) |
| 63 | +pipe.run({"tts": {"text": "Hello from Haystack."}}) |
| 64 | +``` |
| 65 | + |
| 66 | +## Parameters |
| 67 | + |
| 68 | +| Parameter | Default | Notes | |
| 69 | +|---|---|---| |
| 70 | +| `api_key` | `Secret.from_env_var("GANDR_API_KEY")` | Keys start with `gnd_` | |
| 71 | +| `voice` | `gandr-mia` | Also `gandr-ava`, `gandr-jenny`, `gandr-dane`, `gandr-leo`, `gandr-lewis` | |
| 72 | +| `language` | `en` | ISO language code | |
| 73 | +| `sample_rate` | `24000` | One of 8000, 16000, 22050, 24000 | |
| 74 | +| `url` | `https://tts.gandr.ai/v1/tts/bytes` | Override to pin a region | |
| 75 | +| `timeout` | `60.0` | Seconds | |
| 76 | + |
| 77 | +`run()` returns `{"audio": bytes, "path": str | None}`. |
| 78 | + |
| 79 | +The API key is held as a Haystack `Secret` read from the environment, so a |
| 80 | +serialized pipeline never carries the token. An HTTP failure raises |
| 81 | +`RuntimeError` carrying the API's own status and message, so an authentication |
| 82 | +error and a quota error are distinguishable. |
| 83 | + |
| 84 | +## Loading a saved pipeline |
| 85 | + |
| 86 | +Haystack does not deserialize a third-party component unless its module is |
| 87 | +allowlisted: |
| 88 | + |
| 89 | +```python |
| 90 | +from haystack.core.serialization import allow_deserialization_module |
| 91 | + |
| 92 | +allow_deserialization_module("gandr_haystack.tts") |
| 93 | +``` |
| 94 | + |
| 95 | +Or set `HAYSTACK_DESERIALIZATION_ALLOWLIST=gandr_haystack.tts`. Saving with |
| 96 | +`to_dict()` requires nothing. |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +MIT. |
0 commit comments