├── .gitignore ├── .projectile ├── LICENSE ├── README.md └── coqui-tts ├── Dockerfile ├── Dockerfile.gpu ├── Makefile ├── README.md ├── download ├── .gitkeep ├── amd64 │ └── .gitkeep ├── arm64 │ └── .gitkeep └── armv7 │ └── .gitkeep ├── tts ├── tts-server └── tts-train /.gitignore: -------------------------------------------------------------------------------- 1 | /.venv/ 2 | *.whl 3 | __pycache__/ -------------------------------------------------------------------------------- /.projectile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesthesiam/coqui-docker/29a5be31949d88da07fc41f8d7b3f48459e3dae5/.projectile -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Michael Hansen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Coqui Docker 2 | 3 | Docker images for [Coqui AI](https://coqui.ai/) projects. 4 | 5 | ## Available Images 6 | 7 | * [synesthesiam/coqui-tts](coqui-tts) for [Coqui TTS](https://github.com/coqui-ai/TTS) 8 | * Use [tts](coqui-tts/tts) and [tts-server](coqui-tts/tts-server) scripts 9 | * Use [tts-train](coqui-tts/tts-train) for training 10 | -------------------------------------------------------------------------------- /coqui-tts/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7-buster 2 | ARG TARGETARCH 3 | ARG TARGETVARIANT 4 | 5 | ENV LLVM_VERSION=9 6 | 7 | # Deconflict apt locks by platform in cache 8 | RUN echo "Dir::Cache var/cache/apt/${TARGETARCH}${TARGETVARIANT};" > /etc/apt/apt.conf.d/01cache 9 | 10 | RUN --mount=type=cache,id=apt-run,target=/var/apt/cache \ 11 | mkdir -p /var/cache/apt/${TARGETARCH}${TARGETVARIANT}/archives/partial && \ 12 | apt-get update && \ 13 | apt-get install --yes --no-install-recommends \ 14 | espeak-ng wget \ 15 | libatlas3-base libgfortran5 libopenblas-base \ 16 | libmecab-dev 17 | 18 | # Need llvm dev package for arm64 and armv7l 19 | RUN --mount=type=cache,id=apt-run,target=/var/apt/cache \ 20 | if [ ! "${TARGETARCH}${TARGETVARIANT}" = 'amd64' ]; then \ 21 | wget -O - 'http://archive.raspberrypi.org/debian/raspberrypi.gpg.key' | apt-key add - && \ 22 | echo "deb http://archive.raspberrypi.org/debian/ buster main" >> /etc/apt/sources.list && \ 23 | apt-get update && \ 24 | apt-get install --yes --no-install-recommends \ 25 | llvm-${LLVM_VERSION}-dev; \ 26 | fi 27 | 28 | # Create virtual environment so we can use a working pip 29 | RUN --mount=type=cache,id=python-run,target=/var/apt/cache \ 30 | python3 -m venv /app && \ 31 | /app/bin/pip3 install --upgrade pip && \ 32 | /app/bin/pip3 install --upgrade wheel setuptools 33 | 34 | COPY download/${TARGETARCH}${TARGETVARIANT}/ /download/ 35 | 36 | ENV LLVM_CONFIG=/usr/bin/llvm-config-${LLVM_VERSION} 37 | 38 | ENV TORCH_VERSION=1.8.0 39 | 40 | # Install CPU-only PyTorch to save space. 41 | # Pre-compiled ARM wheels require newer numpy. 42 | RUN --mount=type=cache,id=python-run,target=/var/apt/cache \ 43 | /app/bin/pip3 install \ 44 | "torch==${TORCH_VERSION}+cpu" \ 45 | 'numpy==1.20.2' \ 46 | 'scipy==1.6.3' \ 47 | -f https://download.pytorch.org/whl/torch_stable.html \ 48 | -f https://synesthesiam.github.io/prebuilt-apps/index.html \ 49 | -f /download 50 | 51 | ARG TTS_VERSION 52 | 53 | # Remove torch, numpy, and scipy from requirements.txt since we already installed them above. 54 | RUN wget -O "TTS-${TTS_VERSION}.tar.gz" "https://github.com/coqui-ai/TTS/archive/refs/tags/v${TTS_VERSION}.tar.gz" && \ 55 | tar -xf "TTS-${TTS_VERSION}.tar.gz" && \ 56 | cd "TTS-${TTS_VERSION}/" && \ 57 | sed -i '/^\(torch\|numpy\|scipy\)[>=~]/d' requirements.txt 58 | 59 | RUN --mount=type=cache,id=python-run,target=/var/apt/cache \ 60 | /app/bin/pip3 install -r "/TTS-${TTS_VERSION}/requirements.txt" -f /download 61 | 62 | RUN --mount=type=cache,id=python-run,target=/var/apt/cache \ 63 | /app/bin/pip3 install "/TTS-${TTS_VERSION}" -f /download 64 | 65 | # Clean up 66 | RUN rm -f /etc/apt/apt.conf.d/01cache 67 | 68 | # Stop eSpeak from reaching out to pulseaudio, even if told to be silent 69 | ENV PULSE_SERVER='' 70 | 71 | ENV PATH=/app/bin:${PATH} 72 | 73 | ENTRYPOINT ["tts"] 74 | -------------------------------------------------------------------------------- /coqui-tts/Dockerfile.gpu: -------------------------------------------------------------------------------- 1 | FROM nvcr.io/nvidia/pytorch:21.02-py3 2 | 3 | RUN apt-get update && \ 4 | apt-get install --yes --no-install-recommends \ 5 | espeak-ng wget 6 | 7 | COPY download/amd64/ /download/ 8 | 9 | ARG TTS_VERSION 10 | 11 | # Remove torch, numpy, and scipy from requirements.txt since they already exist in the continer 12 | RUN wget -O "TTS-${TTS_VERSION}.tar.gz" "https://github.com/coqui-ai/TTS/archive/refs/tags/v${TTS_VERSION}.tar.gz" && \ 13 | tar -xf "TTS-${TTS_VERSION}.tar.gz" && \ 14 | cd "TTS-${TTS_VERSION}/" && \ 15 | sed -i '/^\(torch\|numpy\|scipy\)[>=~]/d' requirements.txt 16 | 17 | RUN --mount=type=cache,id=python-run,target=/var/apt/cache \ 18 | cd "TTS-${TTS_VERSION}/" && \ 19 | pip install -f /download -r requirements.txt 20 | 21 | RUN --mount=type=cache,id=python-run,target=/var/apt/cache \ 22 | cd "TTS-${TTS_VERSION}/" && \ 23 | pip install -f /download . 24 | 25 | ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 26 | 27 | ENTRYPOINT ["tts"] 28 | -------------------------------------------------------------------------------- /coqui-tts/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: gpu 2 | 3 | SHELL := bash 4 | DOCKER_REGISTRY ?= docker.io 5 | PLATFORMS ?= linux/amd64,linux/arm64,linux/arm/v7 6 | TTS_VERSION ?= 0.1.0 7 | 8 | cpu: 9 | mkdir -p download/amd64 download/arm64 download/armv7 10 | docker buildx build . \ 11 | --build-arg "TTS_VERSION=${TTS_VERSION}" \ 12 | --platform "${PLATFORMS}" \ 13 | --tag "${DOCKER_REGISTRY}/synesthesiam/coqui-tts" \ 14 | --tag "${DOCKER_REGISTRY}/synesthesiam/coqui-tts:${TTS_VERSION}" \ 15 | --push 16 | 17 | gpu: 18 | mkdir -p download/amd64 19 | docker buildx build . -f Dockerfile.gpu \ 20 | --build-arg "TTS_VERSION=${TTS_VERSION}" \ 21 | --tag "${DOCKER_REGISTRY}/synesthesiam/coqui-tts:gpu" \ 22 | --tag "${DOCKER_REGISTRY}/synesthesiam/coqui-tts:gpu-${TTS_VERSION}" \ 23 | --push 24 | -------------------------------------------------------------------------------- /coqui-tts/README.md: -------------------------------------------------------------------------------- 1 | # Coqui TTS Docker 2 | 3 | Docker images and scripts for [Coqui TTS](https://github.com/coqui-ai/TTS) 4 | 5 | ```sh 6 | $ curl https://raw.githubusercontent.com/synesthesiam/coqui-docker/master/coqui-tts/tts-server \ 7 | > ~/bin/tts-server && chmod +755 ~/bin/tts-server 8 | $ tts-server 9 | ``` 10 | 11 | Access TTS server at http://localhost:5002 12 | 13 | ## Scripts Available 14 | 15 | * [`tts-server`](https://raw.githubusercontent.com/synesthesiam/coqui-docker/master/coqui-tts/tts-server) 16 | * Similar to Coqui TTS `tts-server` command 17 | * Server at https://localhost:5002, runs as current user, has access to `$HOME` directory 18 | * Use `--use_cuda true` to use GPU image (requires [nvidia-docker](https://github.com/NVIDIA/nvidia-docker), `amd64` only) 19 | * Use `--update` to update Docker image 20 | * [`tts`](https://raw.githubusercontent.com/synesthesiam/coqui-docker/master/coqui-tts/tts) 21 | * Similar to Coqui TTS `tts` command 22 | * Runs as current user, has access to `$HOME` directory 23 | * Use `--use_cuda true` to use GPU image (requires [nvidia-docker](https://github.com/NVIDIA/nvidia-docker), `amd64` only) 24 | * Use `--update` to update Docker image 25 | * [`tts-train`](https://raw.githubusercontent.com/synesthesiam/coqui-docker/master/coqui-tts/tts-train) 26 | * Runs script from `TTS/bin` (e.g., `tts-train train_tts.py ...`) 27 | * Runs as root, has access to `$HOME` directory 28 | * Requires [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) (`amd64` only) 29 | * Use `--update` to update Docker image 30 | 31 | ## Images Available 32 | 33 | For CPU-only: 34 | 35 | ```sh 36 | $ docker pull synesthesiam/coqui-tts 37 | ``` 38 | 39 | For GPU (`amd64` only): 40 | 41 | ```sh 42 | $ docker pull synesthesiam/coqui-tts:gpu 43 | ``` 44 | 45 | Docker images also tagged with `` or `gpu-` for the version of Coqui TTS. 46 | 47 | Supported versions: 48 | 49 | * 0.1.0 50 | * 0.0.13.2 51 | 52 | ## Platforms Supported 53 | 54 | * `amd64` - laptops/desktops/servers 55 | * GPU-ready images have `gpu` tag instead of `latest` 56 | * Run `tts-server --use_cuda true` 57 | * `armv7l` - Raspberry Pi 3/4 32-bit 58 | * `arm64` - Raspberry Pi 3/4 64-bit 59 | -------------------------------------------------------------------------------- /coqui-tts/download/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesthesiam/coqui-docker/29a5be31949d88da07fc41f8d7b3f48459e3dae5/coqui-tts/download/.gitkeep -------------------------------------------------------------------------------- /coqui-tts/download/amd64/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesthesiam/coqui-docker/29a5be31949d88da07fc41f8d7b3f48459e3dae5/coqui-tts/download/amd64/.gitkeep -------------------------------------------------------------------------------- /coqui-tts/download/arm64/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesthesiam/coqui-docker/29a5be31949d88da07fc41f8d7b3f48459e3dae5/coqui-tts/download/arm64/.gitkeep -------------------------------------------------------------------------------- /coqui-tts/download/armv7/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesthesiam/coqui-docker/29a5be31949d88da07fc41f8d7b3f48459e3dae5/coqui-tts/download/armv7/.gitkeep -------------------------------------------------------------------------------- /coqui-tts/tts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Run tts --update to update Docker image 4 | # Run tts --gpu to use GPU image 5 | 6 | args=() 7 | tag='latest' 8 | docker='docker' 9 | 10 | while [[ -n "$1" ]]; do 11 | if [[ -n "${check_cuda_arg}" ]]; then 12 | case "$1" in 13 | 'true' | '1' | 'yes') 14 | # Use GPU version 15 | docker='nvidia-docker' 16 | tag='gpu' 17 | ;; 18 | esac 19 | 20 | check_cuda_arg='' 21 | fi 22 | 23 | if [[ "$1" == '--update' ]]; then 24 | # Update Docker image 25 | update='1' 26 | elif [[ "$1" == '--use_cuda' ]]; then 27 | # Check next argument 28 | check_cuda_arg='1' 29 | args+=("$1") 30 | else 31 | args+=("$1") 32 | fi 33 | 34 | shift 1 35 | done 36 | 37 | if [[ -n "${update}" ]]; then 38 | docker pull "synesthesiam/coqui-tts:${tag}" 39 | fi 40 | 41 | "${docker}" run \ 42 | -it \ 43 | -e "HOME=${HOME}" \ 44 | -v "$HOME:${HOME}" \ 45 | -w "${PWD}" \ 46 | --user "$(id -u):$(id -g)" \ 47 | "synesthesiam/coqui-tts:${tag}" \ 48 | "${args[@]}" 49 | -------------------------------------------------------------------------------- /coqui-tts/tts-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Run tts --update to update Docker image 4 | # Run tts --use_cuda to use GPU image 5 | 6 | args=() 7 | tag='latest' 8 | docker='docker' 9 | 10 | while [[ -n "$1" ]]; do 11 | if [[ -n "${check_cuda_arg}" ]]; then 12 | case "$1" in 13 | 'true' | '1' | 'yes') 14 | # Use GPU version 15 | docker='nvidia-docker' 16 | tag='gpu' 17 | ;; 18 | esac 19 | 20 | check_cuda_arg='' 21 | fi 22 | 23 | if [[ "$1" == '--update' ]]; then 24 | # Update Docker image 25 | update='1' 26 | elif [[ "$1" == '--use_cuda' ]]; then 27 | # Check next argument 28 | check_cuda_arg='1' 29 | args+=("$1") 30 | else 31 | args+=("$1") 32 | fi 33 | 34 | shift 1 35 | done 36 | 37 | if [[ -n "${update}" ]]; then 38 | docker pull "synesthesiam/coqui-tts:${tag}" 39 | fi 40 | 41 | "${docker}" run \ 42 | -it \ 43 | -e "HOME=${HOME}" \ 44 | -v "$HOME:${HOME}" \ 45 | -w "${PWD}" \ 46 | -p 5002:5002 \ 47 | --user "$(id -u):$(id -g)" \ 48 | --entrypoint 'tts-server' \ 49 | "synesthesiam/coqui-tts:${tag}" \ 50 | "${args[@]}" 51 | -------------------------------------------------------------------------------- /coqui-tts/tts-train: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Run tts-train --update to update Docker image 4 | 5 | args=() 6 | tag='gpu' 7 | 8 | while [[ -n "$1" ]]; do 9 | if [[ "$1" == '--update' ]]; then 10 | # Update Docker image 11 | update='1' 12 | else 13 | args+=("$1") 14 | fi 15 | 16 | shift 1 17 | done 18 | 19 | if [[ -n "${update}" ]]; then 20 | docker pull "synesthesiam/coqui-tts:${tag}" 21 | fi 22 | 23 | if [[ -z "${args[*]}" ]]; then 24 | echo "Script name is required (from TTS/bin)" 25 | exit 1 26 | fi 27 | 28 | # Fix path 29 | args[0]="/opt/conda/lib/python3.8/site-packages/TTS/bin/${args[0]}" 30 | 31 | nvidia-docker run \ 32 | -it \ 33 | -v "$HOME:${HOME}" \ 34 | -w "${PWD}" \ 35 | --entrypoint 'python3' \ 36 | "synesthesiam/coqui-tts:${tag}" \ 37 | "${args[@]}" 38 | --------------------------------------------------------------------------------