Periodic cleanup of generated WAV files

This commit is contained in:
ekoc committed 2025-03-14 22:26:02 +01:00
1 parent 64081dcabd
commit 3a9fc4554a
4 files changed
+38 -9

No files matched your search

+1
View File
@@ -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.
+31 -9
View File
@@ -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 <<EOR
echo "* * * * * ${ALLTALK_DIR}/cleanup-wavs.sh" > /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"]
ENTRYPOINT ["bash", "-c", "./start_alltalk.sh"]
+5
View File
@@ -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 \
+1
View File
@@ -24,6 +24,7 @@ RUN <<EOR
apt-get upgrade -y
apt-get install --no-install-recommends -y \
espeak-ng \
cron \
curl \
wget \
jq \