|
| 1 | +# Docker Usage Guide for PyThaiTTS |
| 2 | + |
| 3 | +This guide explains how to build and run PyThaiTTS using Docker. |
| 4 | + |
| 5 | +## Building the Docker Image |
| 6 | + |
| 7 | +To build the Docker image, run the following command from the root directory of the repository: |
| 8 | + |
| 9 | +```bash |
| 10 | +docker build -t pythaitts:latest . |
| 11 | +``` |
| 12 | + |
| 13 | +This will create a Docker image named `pythaitts:latest` with all dependencies installed. |
| 14 | + |
| 15 | +## Running the Demo |
| 16 | + |
| 17 | +To run the demo script that demonstrates Thai text-to-speech synthesis: |
| 18 | + |
| 19 | +```bash |
| 20 | +docker run --rm pythaitts:latest |
| 21 | +``` |
| 22 | + |
| 23 | +The demo will: |
| 24 | +1. Initialize the PyThaiTTS model (default: lunarlist_onnx) |
| 25 | +2. Generate speech from Thai text |
| 26 | +3. Save the output to a WAV file |
| 27 | +4. Display the waveform information |
| 28 | + |
| 29 | +## Custom Usage |
| 30 | + |
| 31 | +### Interactive Shell |
| 32 | + |
| 33 | +To start an interactive shell inside the container: |
| 34 | + |
| 35 | +```bash |
| 36 | +docker run --rm -it pythaitts:latest /bin/bash |
| 37 | +``` |
| 38 | + |
| 39 | +### Run Custom Python Script |
| 40 | + |
| 41 | +To run your own Python script: |
| 42 | + |
| 43 | +```bash |
| 44 | +docker run --rm -v $(pwd)/your_script.py:/app/custom.py pythaitts:latest python custom.py |
| 45 | +``` |
| 46 | + |
| 47 | +### Save Output Files |
| 48 | + |
| 49 | +To save generated audio files to your host machine: |
| 50 | + |
| 51 | +```bash |
| 52 | +docker run --rm -v $(pwd)/output:/app/output pythaitts:latest python -c " |
| 53 | +from pythaitts import TTS |
| 54 | +tts = TTS() |
| 55 | +tts.tts('สวัสดีครับ', filename='output/hello.wav') |
| 56 | +" |
| 57 | +``` |
| 58 | + |
| 59 | +This will save the generated `hello.wav` file to the `output` directory on your host machine. |
| 60 | + |
| 61 | +## Example Usage in Python |
| 62 | + |
| 63 | +Inside the container, you can use PyThaiTTS as follows: |
| 64 | + |
| 65 | +```python |
| 66 | +from pythaitts import TTS |
| 67 | + |
| 68 | +# Initialize TTS with default model |
| 69 | +tts = TTS() |
| 70 | + |
| 71 | +# Generate speech and save to file |
| 72 | +file_path = tts.tts("ภาษาไทย ง่าย มาก มาก", filename="output.wav") |
| 73 | +print(f"Audio saved to: {file_path}") |
| 74 | + |
| 75 | +# Generate speech and get waveform |
| 76 | +waveform = tts.tts("ภาษาไทย ง่าย มาก มาก", return_type="waveform") |
| 77 | +print(f"Waveform shape: {waveform.shape}") |
| 78 | +``` |
| 79 | + |
| 80 | +## Available TTS Models |
| 81 | + |
| 82 | +PyThaiTTS supports multiple models: |
| 83 | + |
| 84 | +- **lunarlist_onnx** (default): ONNX-optimized model, CPU-only |
| 85 | +- **khanomtan**: KhanomTan TTS model |
| 86 | +- **lunarlist**: Original Lunarlist model |
| 87 | + |
| 88 | +To use a different model: |
| 89 | + |
| 90 | +```python |
| 91 | +from pythaitts import TTS |
| 92 | + |
| 93 | +# Using KhanomTan model |
| 94 | +tts = TTS(pretrained="khanomtan", version="1.0") |
| 95 | +``` |
| 96 | + |
| 97 | +## Requirements |
| 98 | + |
| 99 | +- Docker installed on your system |
| 100 | +- At least 2GB of available disk space |
| 101 | +- Internet connection for downloading models on first run |
| 102 | + |
| 103 | +## Troubleshooting |
| 104 | + |
| 105 | +If you encounter issues with model downloads, ensure: |
| 106 | +1. You have a stable internet connection |
| 107 | +2. The Hugging Face Hub is accessible from your network |
| 108 | +3. You have sufficient disk space for model files |
| 109 | + |
| 110 | +## Notes |
| 111 | + |
| 112 | +- The first run will download model files from Hugging Face Hub, which may take some time depending on your internet connection |
| 113 | +- Generated audio files are in WAV format |
| 114 | +- The default model (lunarlist_onnx) runs on CPU and doesn't require GPU support |
0 commit comments