diff --git a/DOCKER_README.md b/DOCKER_README.md index 496e7ae..098f883 100644 --- a/DOCKER_README.md +++ b/DOCKER_README.md @@ -54,6 +54,7 @@ following optional arguments: - `--rvc-voices` similar to voices, this option lets you pick the folder containing the [RVC models](https://github.com/erew123/alltalk_tts/wiki/RVC-(Retrieval%E2%80%90based-Voice-Conversion)). - Example: `docker-start.sh --rvc_voices /my/rvc/voices/dir` - `--no-ui` allows you to not expose port 7852 for the gradio interface and sets `launch_gradio` and `gradio_interface` to `false`. +- `--auto-cleanup` periodically deletes all generated WAV files that are older than 1min. - `--with-multi-engine-manager` enables the use of the [multi engine manager (MEM)](https://github.com/erew123/alltalk_tts/wiki/Multi-Engine-Manager) which allows for more parallel requests. By default, one TTS engine is started. Optionally, you can pass the file path of a JSON file which can be a subset of `mem_config.json` with more fine-grained configuration options. diff --git a/Dockerfile b/Dockerfile index bcec9b5..2b0baf9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -139,9 +139,19 @@ merge_json_files() { replace_env_vars docker_default_confignew.json merge_json_files confignew.json +# Script for deleting WAV files that are older than 1 minute: +cat << EOF2 > ${ALLTALK_DIR}/cleanup-wavs.sh +#!/usr/bin/env bash +[ \"\$ALLTALK_AUTO_CLEANUP\" = \"true\" ] && find ${ALLTALK_DIR}/outputs -type f -name "*.wav" -mmin +1 -exec rm {} \; +EOF2 +chmod u+x ${ALLTALK_DIR}/cleanup-wavs.sh + +# Starting the cron job: +cron + source ${ALLTALK_DIR}/conda_env.sh -if [ "\$ALLTALK_ENABLE_MULTI_ENGINE_MANAGER" = true ] ; then +if [ "\$ALLTALK_ENABLE_MULTI_ENGINE_MANAGER" = "true" ] ; then echo "Starting alltalk using multi engine manager" replace_env_vars docker_default_mem_config.json merge_json_files mem_config.json @@ -171,6 +181,25 @@ EOR COPY --chown=alltalk:alltalk . . +RUN mkdir -p ${ALLTALK_DIR}/outputs ${ALLTALK_DIR}/.triton/autotune + +############################################################################## +# Enable deepspeed for all models: +############################################################################## +RUN find . -name model_settings.json -exec sed -i -e 's/"deepspeed_enabled": false/"deepspeed_enabled": true/g' {} \; + +############################################################################## +# Cronjob running every minute to delete output WAV files: +############################################################################## +USER root +RUN < /etc/cron.d/cleanup-wavs + crontab -u alltalk /etc/cron.d/cleanup-wavs + chmod u+s /usr/sbin/cron +EOR + +USER alltalk + ############################################################################## # Create script to execute firstrun.py and run it: ############################################################################## @@ -182,14 +211,7 @@ python ./system/config/firstrun.py $@' > ./start_firstrun.sh RUN chmod +x start_firstrun.sh RUN ./start_firstrun.sh --tts_model $TTS_MODEL -RUN mkdir -p ${ALLTALK_DIR}/outputs ${ALLTALK_DIR}/.triton/autotune - -############################################################################## -# Enable deepspeed for all models: -############################################################################## -RUN find . -name model_settings.json -exec sed -i -e 's/"deepspeed_enabled": false/"deepspeed_enabled": true/g' {} \; - ############################################################################## # Start alltalk: ############################################################################## -ENTRYPOINT ["sh", "-c", "./start_alltalk.sh"] \ No newline at end of file +ENTRYPOINT ["bash", "-c", "./start_alltalk.sh"] \ No newline at end of file diff --git a/docker-start.sh b/docker-start.sh index 1eefaa6..e8b6bc3 100755 --- a/docker-start.sh +++ b/docker-start.sh @@ -9,6 +9,7 @@ MULTI_ENGINE_MANAGER_CONFIG= DOCKER_TAG=latest-xtts DOCKER_REPOSITORY=erew123 ALLTALK_DIR=/home/alltalk +ALLTALK_AUTO_CLEANUP=false declare -a ADDITIONAL_ARGS=() # Parse arguments @@ -29,6 +30,9 @@ while [ "$#" -gt 0 ]; do --no-ui) ALLTALK_GRADIO_INTERFACE=false ;; + --auto-cleanup) + ALLTALK_AUTO_CLEANUP=true + ;; --with-multi-engine-manager) ALLTALK_ENABLE_MULTI_ENGINE_MANAGER=true if [ -n "$2" ] && ! [[ $2 =~ ^--.* ]]; then @@ -91,6 +95,7 @@ fi DOCKER_ARGS+=( -e ALLTALK_ENABLE_MULTI_ENGINE_MANAGER=${ALLTALK_ENABLE_MULTI_ENGINE_MANAGER} ) DOCKER_ARGS+=( -e ALLTALK_GRADIO_INTERFACE=${ALLTALK_GRADIO_INTERFACE} ) DOCKER_ARGS+=( -e ALLTALK_LAUNCH_GRADIO=${ALLTALK_GRADIO_INTERFACE} ) +DOCKER_ARGS+=( -e ALLTALK_AUTO_CLEANUP=${ALLTALK_AUTO_CLEANUP} ) docker run \ diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 46af3f3..91d119b 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -24,6 +24,7 @@ RUN <