Commit before cleanup
This commit is contained in:
parent
24b7081f79
commit
7fc43933e5
18 changed files with 797 additions and 29 deletions
189
Dockerfile.debian
Normal file
189
Dockerfile.debian
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
# Copyright 2022 Mycroft AI Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
# Dockerfile for Mimic 3 (https://github.com/MycroftAI/mimic3)
|
||||
#
|
||||
# Creates self-contained binaries using PyInstaller
|
||||
# (https://pyinstaller.readthedocs.io/en/stable/).
|
||||
#
|
||||
# Packages into a Debian (.deb) package.
|
||||
#
|
||||
# Requires Docker buildx: https://docs.docker.com/buildx/working-with-buildx/
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
FROM debian:bullseye as build
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN echo "Dir::Cache var/cache/apt/${TARGETARCH}${TARGETVARIANT};" > /etc/apt/apt.conf.d/01cache
|
||||
|
||||
RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \
|
||||
mkdir -p /var/cache/apt/${TARGETARCH}${TARGETVARIANT}/archives/partial && \
|
||||
apt-get update && \
|
||||
apt-get install --yes --no-install-recommends \
|
||||
python3 python3-pip python3-venv \
|
||||
build-essential python3-dev \
|
||||
libespeak-ng1 dpkg-dev rsync gettext-base
|
||||
|
||||
WORKDIR /build/mimic3
|
||||
|
||||
COPY opentts-abc/ ./opentts-abc/
|
||||
COPY mimic3-http/ ./mimic3-http/
|
||||
COPY mimic3-tts/ ./mimic3-tts/
|
||||
COPY install.sh ./
|
||||
|
||||
# Install mimic3
|
||||
RUN --mount=type=cache,id=pip-venv,target=/root/.cache/pip \
|
||||
PIP_INSTALL='install -f https://synesthesiam.github.io/prebuilt-apps/' \
|
||||
./install.sh
|
||||
|
||||
# Install PyInstaller
|
||||
RUN --mount=type=cache,id=pip-venv,target=/root/.cache/pip \
|
||||
.venv/bin/pip3 install 'pyinstaller>=4,<5'
|
||||
|
||||
COPY pyinstaller/mimic3.py ./pyinstaller/
|
||||
|
||||
# Create binary
|
||||
RUN .venv/bin/pyinstaller \
|
||||
--noconfirm \
|
||||
--name mimic3 \
|
||||
--hidden-import 'pycrfsuite._dumpparser' \
|
||||
--hidden-import 'pycrfsuite._logparser' \
|
||||
--collect-binaries 'onnxruntime' \
|
||||
--collect-data 'gruut' \
|
||||
--hidden-import "gruut_lang_de" \
|
||||
--collect-data "gruut_lang_de" \
|
||||
--hidden-import "gruut_lang_en" \
|
||||
--collect-data "gruut_lang_en" \
|
||||
--hidden-import "gruut_lang_es" \
|
||||
--collect-data "gruut_lang_es" \
|
||||
--hidden-import "gruut_lang_fr" \
|
||||
--collect-data "gruut_lang_fr" \
|
||||
--hidden-import "gruut_lang_it" \
|
||||
--collect-data "gruut_lang_it" \
|
||||
--hidden-import "gruut_lang_nl" \
|
||||
--collect-data "gruut_lang_nl" \
|
||||
--hidden-import "gruut_lang_ru" \
|
||||
--collect-data "gruut_lang_ru" \
|
||||
--hidden-import "gruut_lang_sw" \
|
||||
--collect-data "gruut_lang_sw" \
|
||||
--hidden-import "gruut_lang_fa" \
|
||||
--collect-data "gruut_lang_fa" \
|
||||
--collect-data 'espeak_phonemizer' \
|
||||
--collect-data 'phonemes2ids' \
|
||||
--hidden-import 'swagger_ui' \
|
||||
--hidden-import 'epitran' \
|
||||
--hidden-import 'hazm' \
|
||||
--collect-data 'hazm' \
|
||||
--collect-data 'panphon' \
|
||||
--collect-data 'mimic3_tts' \
|
||||
--collect-data 'mimic3_http' \
|
||||
pyinstaller/mimic3.py
|
||||
|
||||
# Have to manually copy these over for some reason
|
||||
RUN find .venv -name 'wapiti' -type d -exec cp -R {} dist/mimic3/ \;
|
||||
RUN find .venv -name 'libwapiti.*.so' -type f -exec cp {} dist/mimic3/ \;
|
||||
|
||||
# Clean up unused lexicons
|
||||
RUN find dist/mimic3/ -wholename '*/gruut_lang_*/espeak' -type d | \
|
||||
while read -r espeak_dir; do \
|
||||
rm -rf "${espeak_dir}"; \
|
||||
done
|
||||
|
||||
# Copy convenience scripts
|
||||
COPY pyinstaller/mimic3-server \
|
||||
pyinstaller/mimic3-download \
|
||||
dist/mimic3/
|
||||
|
||||
# Create Debian package
|
||||
ENV package_dir=/package/mimic3-tts
|
||||
|
||||
COPY debian/ debian/
|
||||
COPY voices/ voices/
|
||||
|
||||
RUN mkdir -p "${package_dir}/DEBIAN" && \
|
||||
export VERSION="$(cat mimic3-tts/mimic3_tts/VERSION)" && \
|
||||
export DEBIAN_ARCH="$(dpkg-architecture | grep '^DEB_HOST_ARCH=' | sed -e 's/^.\+=//')" && \
|
||||
envsubst \
|
||||
< "debian/control.in" \
|
||||
> "${package_dir}/DEBIAN/control" && \
|
||||
mkdir -p "${package_dir}/usr/lib/mimic3-tts" && \
|
||||
rsync -av "dist/mimic3/" "${package_dir}/usr/lib/mimic3-tts/" && \
|
||||
mkdir -p "${package_dir}/usr/bin/" && \
|
||||
rsync -av "debian/bin/" "${package_dir}/usr/bin/" && \
|
||||
export dest_voice_dir="${package_dir}/usr/share/mimic3/voices/en_UK/apope_low" && \
|
||||
mkdir -p "${dest_voice_dir}" && \
|
||||
rsync -av "voices/en_UK/apope_low/" "${dest_voice_dir}/" && \
|
||||
cd /package && \
|
||||
dpkg --build 'mimic3-tts' && \
|
||||
dpkg-name ./*.deb
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
FROM debian:bullseye as test
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN echo "Dir::Cache var/cache/apt/${TARGETARCH}${TARGETVARIANT};" > /etc/apt/apt.conf.d/01cache
|
||||
|
||||
RUN --mount=type=cache,id=apt-run,target=/var/cache/apt \
|
||||
mkdir -p /var/cache/apt/${TARGETARCH}${TARGETVARIANT}/archives/partial && \
|
||||
apt-get update && \
|
||||
apt-get install --yes --no-install-recommends \
|
||||
dpkg-dev
|
||||
|
||||
WORKDIR /test
|
||||
|
||||
COPY --from=build /package/*.deb ./
|
||||
COPY mimic3-tts/mimic3_tts/VERSION ./
|
||||
|
||||
# Install mimic3 for current architecture
|
||||
RUN --mount=type=cache,id=apt-run,target=/var/cache/apt \
|
||||
export mimic3_version="$(cat VERSION)" && \
|
||||
dpkg-architecture | \
|
||||
grep 'DEB_HOST_ARCH=' | \
|
||||
sed -e 's/.\+=//' | \
|
||||
xargs printf "./mimic3-tts_${mimic3_version}_%s.deb" | \
|
||||
xargs apt install --yes
|
||||
|
||||
# Run test
|
||||
COPY tests/apope_sample.txt tests/apope_sample_*.wav tests/
|
||||
|
||||
# Generate sample and check
|
||||
RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav" && \
|
||||
mimic3 \
|
||||
--deterministic \
|
||||
--voice 'en_UK/apope_low' \
|
||||
< tests/apope_sample.txt \
|
||||
> tests/actual_sample.wav && \
|
||||
diff tests/actual_sample.wav "${expected_sample}"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
FROM scratch
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
COPY --from=build /package/*.deb /
|
||||
|
||||
# Ensure test runs
|
||||
COPY --from=test /test/tests/actual_sample.wav "/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav"
|
||||
Loading…
Add table
Add a link
Reference in a new issue