File size: 4,221 Bytes
b840c7e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | # text-to-speech-maya
A small playground for the Maya text-to-speech inference handler and a FastAPI test server.
## Run the FastAPI test server (local)
1. Install dependencies. Follow the official PyTorch instructions for your platform first (CPU/MPS/CUDA), then install the remaining requirements:
```bash
# Example: install torch from https://pytorch.org/ for your system first, then:
pip install -r inference_endpoints/requirements.txt
```
2. Start the server (set `MAYA_MODEL_PATH` to your model path if needed):
```bash
export MAYA_MODEL_PATH="/path/to/maya_model"
uvicorn server.app:app --reload --host 0.0.0.0 --port 8000
```
3. Test the synthesis endpoint (saves `output.wav`):
```bash
curl -X POST "http://localhost:8000/synthesize" -H "Content-Type: application/json" -d '{
"description": "neutral female voice",
"text": "Hello world from Maya TTS"
}' --output output.wav
```
Notes
- The `EndpointHandler` expects the Maya model to be compatible with the SNAC decoder flow; you may need to adapt token decoding depending on the actual model outputs.
- `torch` often requires platform-specific wheels; if `pip install -r` fails for `torch`, install the appropriate wheel from pytorch.org first then re-run the requirements install for the remaining packages.
---
## VSCode setup (recommended)
The repo includes helper files to make development in VSCode convenient: a workspace `.venv`, editor settings, tasks, and launch configurations.
1. Create and activate a workspace venv (the Makefile has a helper):
```bash
make venv
source .venv/bin/activate
```
2. Install project requirements into the venv:
```bash
pip install -r inference_endpoints/requirements.txt
# dev tools for formatting & linting
pip install black flake8
```
3. Open this folder in VSCode. The workspace settings point to `${workspaceFolder}/.venv/bin/python` and the Python extension will activate the venv in the terminal.
4. Useful VSCode features included:
- Formatting: `Black` is configured and will run on save (line length 88).
- Linting: `flake8` is enabled; run it using the Tasks panel or via the command palette.
- Tasks: Run `Format: black`, `Lint: flake8`, or `Run server (run.sh)` from the Tasks menu.
- Launch: Use the `Run FastAPI (uvicorn)` launch configuration to start the server with debugging enabled. It will load `server/.env` for environment variables.
5. Running the server from VSCode:
- Use the Run panel and choose `Run FastAPI (uvicorn)` to start with the debugger.
- Or open the integrated terminal, ensure the venv is active, and run:
```bash
./run.sh
```
6. Poetry users
If you prefer Poetry for the server package, there's a `server/pyproject.toml`. From `server/` run:
```bash
poetry install
poetry run uvicorn server.app:app --reload --host 0.0.0.0 --port 8000
```
---
If you want I can add a short checklist or developer guide in `DEVELOPING.md` with these steps and troubleshooting tips.
# text-to-speech-maya
A small playground for the Maya text-to-speech inference handler and a FastAPI test server.
## Run the FastAPI test server (local)
1. Install dependencies. Follow the official PyTorch instructions for your platform first (CPU/MPS/CUDA), then install the remaining requirements:
```bash
# Example: install torch from https://pytorch.org/ for your system first, then:
pip install -r inference_endpoints/requirements.txt
```
2. Start the server (set `MAYA_MODEL_PATH` to your model path if needed):
```bash
export MAYA_MODEL_PATH="/path/to/maya_model"
uvicorn server.app:app --reload --host 0.0.0.0 --port 8000
```
3. Test the synthesis endpoint (saves `output.wav`):
```bash
curl -X POST "http://localhost:8000/synthesize" -H "Content-Type: application/json" -d '{
"description": "neutral female voice",
"text": "Hello world from Maya TTS"
}' --output output.wav
```
Notes
- The `EndpointHandler` expects the Maya model to be compatible with the SNAC decoder flow; you may need to adapt token decoding depending on the actual model outputs.
- `torch` often requires platform-specific wheels; if `pip install -r` fails for `torch`, install the appropriate wheel from pytorch.org first then re-run the requirements install for the remaining packages.
|