Compare commits

...
Author SHA1 Message Date
Paladinium 3d4b94be7d Merge pull request #567 from Paladinium/main_improve_github_actions
Improve paths-filter for Docker github action
2025-03-19 21:50:25 +01:00
ekoc 1c66968873 Improve paths-filter for Docker github action 2025-03-19 21:49:34 +01:00
erew123 492dbe58c0 Merge pull request #543 from Paladinium/main
Adding Github actions for building Docker to main
2025-02-27 06:40:00 +00:00
ekoc 871a100a8a Adding Github actions for building the docker images 2025-02-26 21:28:48 +01:00
ekoc 3aacf3f27f Adding Github actions for building the docker images 2025-02-26 20:21:46 +01:00
ekoc fbd09a24b6 Adding Github actions for building the docker images 2025-02-22 16:40:25 +01:00
erew123 f6669c912c Update feature_request.md 2024-12-08 03:17:17 +00:00
erew123 6a45c03b04 Update python-ci.yml 2024-11-27 19:45:22 +00:00
erew123 84a28ca95c Update publish-docker.yml 2024-11-27 19:45:01 +00:00
erew123 6fda08cb53 Delete .github/workflows/main.yml 2024-11-27 03:55:36 +00:00
erew123 754cfeed9e Create python-ci.yml 2024-11-27 03:53:39 +00:00
erew123 e61aaca243 Create main.yml 2024-11-27 03:51:26 +00:00
erew123 8828ecb3af Update publish-docker.yml 2024-11-27 03:15:00 +00:00
erew123 abd1e4f13f Update README.md 2024-11-24 22:24:40 +00:00
erew123 a6b3a77fd8 Update README.md 2024-11-24 22:24:10 +00:00
erew123 d304032279 Update README.md 2024-11-24 20:23:49 +00:00
erew123 f4bc0081f4 Update README.md 2024-11-11 14:08:06 +00:00
erew123 1ff02ce1a4 Update README.md 2024-10-16 00:27:20 +01:00
erew123 5e39b546ef Update README.md 2024-10-16 00:26:30 +01:00
erew123 a39a4ebb89 Update README.md 2024-10-05 23:34:54 +01:00
erew123 510bc2d1a3 Update README.md 2024-08-15 09:27:17 +01:00
erew123 4ca5ae68ea Update requirements_textgen.txt 2024-08-15 09:03:58 +01:00
erew123 1a8a20f4ee Add files via upload 2024-07-01 09:57:58 +01:00
erew123 80eb4e5302 Merge pull request #249 from dpkirchner/tune-docker
Tune docker
2024-06-19 10:50:14 +01:00
erew123 9ff0bf10ab Wrong upload (no actual change here)
Must be careful to watch github swapping between branches when uploading!
2024-06-17 21:02:19 +01:00
erew123 d020a0f9a2 removed debug lines 2024-06-17 21:00:08 +01:00
erew123 012b987ab8 Force PyTorch 2.2.1 2024-06-14 13:10:17 +01:00
David Kirchner 24a0a457a1 Add a health check to docker compose (monitor with docker ps) 2024-06-11 10:47:25 -07:00
David Kirchner 663e267d4c Allow user to specify a docker image using compose
This makes it easier to test local changes. Usage is basically:

$ docker build -t whatever:latest .
$ IMAGE=whatever:latest docker compose up -d
2024-06-11 09:36:26 -07:00
David Kirchner f174a61aee Reorder dockerfile to avoid rebuilding modules on all code changes 2024-06-11 09:28:55 -07:00
erew123 c9b5aef80b Update README.md 2024-06-06 23:23:18 +01:00
erew123 f107173b58 Update README.md 2024-06-06 21:16:39 +01:00
erew123 9b530eda75 Update README.md 2024-06-06 21:16:20 +01:00
erew123 7c7cb72c13 Updated to deal with Gradio 4.xx versions 2024-05-14 21:01:38 +01:00
erew123 3a105ce922 Update tts_server.py
Set API Local to use float as Transformers demands it
2024-05-14 18:19:29 +01:00
erew123 690018c4ab Test code rework to allow custom file names.
Contains a box to add a custom file name. Files are generated in the format {custom-file-name}_{ID_number_XXXXX}_{uuid}

This allows up to 99,999 files generated in 1x single session. 

The uuid needs to be applied to ensure files are not over-written and handle browser based caching of wav files.
2024-05-12 14:00:10 +01:00
erew123 6808439ca1 nailed text-gen-webui spacy version
Added spacy>=3.7.2 to stop the requirements installation hunting around for Spacy versions so much.

Tested this on a fresh install of Text-gen-webui and it ran through without issue.
2024-05-06 23:40:39 +01:00
erew123 8cf56faad2 run dos2unix to repair crlf to lf 2024-05-06 01:39:01 +01:00
erew123 cb7d486288 run dos2unix to repair crlf to lf 2024-05-06 01:38:04 +01:00
erew123 086999fc1b Update atsetup.sh 2024-05-02 23:26:42 +01:00
erew123 a1b889108f Faster narration generation w/low vram
Moved the memory management of the TTS model into the narrator so that it doesnt shift the model backwards and forwards VRAM<>System ram on each portion of the generation. Only the beginning and end. Only benefits when Low VRAM is enabled, but should shave a few seconds of generation of your average generation.
2024-05-01 16:09:59 +01:00
erew123 9f18b24465 Changed how dvae weights are copied. 2024-05-01 02:38:24 +01:00
erew123 a3f157249c Small change to splitting of text 2024-04-28 21:14:25 +01:00
erew123 eb08d31509 Added Streaming Stopping
Currently this is in testing. 

curl -X POST http://localhost:7851/api/stop-generation

Would stop the current streaming generation.

This is more a v2 feature that is just getting tried out by someone else ATM.
2024-04-28 20:37:41 +01:00
erew123 1e1b7fdd8c Merge pull request #190 from ytt246/main
Edited text cleaning to support some commonly used fullwidth/CJK punctuations
2024-04-28 11:12:32 +01:00
IAUSHYJ 5aad7bcc45 tts generater split fix 2024-04-28 00:15:29 +04:00
erew123 dd52597f49 Grad acc steps min setting 2024-04-26 20:50:52 +01:00
erew123 5f836e08b8 Various updates
additional documentation
learning rate selectable
custom folder paths for saving model
selectable model on saving
2024-04-26 15:30:53 +01:00
IAUSHYJ b89b6cdc1d small fix 2024-04-26 13:23:23 +04:00
IAUSHYJ 558aed1888 stop cleaning common chinese punctuations 2024-04-26 03:40:20 +04:00
erew123 5eab3d28df Add files via upload 2024-04-25 21:25:29 +01:00
erew123 fd76f496a0 re-jigged language support/filters 2024-04-25 21:24:44 +01:00
erew123 4d9b44d9a0 Update tts_generator.html 2024-04-25 18:06:49 +01:00
erew123 951df5a239 Update atsetup.bat 2024-04-24 18:40:38 +01:00
erew123 0a35ee2310 Update atsetup.bat 2024-04-24 18:38:32 +01:00
erew123 efeb2e67e0 Add files via upload 2024-04-20 14:54:33 +01:00
erew123 131f14de76 Add files via upload 2024-04-20 14:49:03 +01:00
erew123 4e67931fe9 bug fix 2024-04-20 10:28:18 +01:00
erew123 785525327d Update README.md 2024-04-18 20:07:20 +01:00
erew123 d4647573cd Add files via upload 2024-04-18 19:58:31 +01:00
erew123 c3895b602c Hindi Support 2024-04-18 18:43:25 +01:00
erew123 f18eb9a4a0 Hindi Support 2024-04-18 18:39:10 +01:00
erew123 2834778e8f Added Hindi finetune.py 2024-04-18 18:32:10 +01:00
erew123 2f42c69d25 Update README.md 2024-04-18 15:57:32 +01:00
erew123 8c65f026e6 ST AllTalk FT Model
changed a value for detecting FT model.
2024-04-09 01:17:03 +01:00
erew123 fff01107c8 Update tts_server.py - API request console output 2024-04-06 11:45:32 +01:00
erew123 0bdc66f6e5 Add files via upload 2024-04-05 12:28:59 +01:00
erew123 1c3fc86085 Delete system/at_admin/textnotinside-min.jpg 2024-04-05 12:28:38 +01:00
erew123 d9eb0876a6 Delete system/at_admin/pythonrequirementswindows-min.jpg 2024-04-05 12:28:30 +01:00
erew123 9b4130a8eb Delete system/at_admin/pythonenvironment-min.jpg 2024-04-05 12:28:22 +01:00
erew123 8fb5b4f695 Delete system/at_admin/deepspeedexample-min.jpg 2024-04-05 12:28:14 +01:00
erew123 65e306a198 Delete system/at_admin/atandsdplugin-min.jpg 2024-04-05 12:28:07 +01:00
erew123 3dabb63656 Delete system/at_admin/4abed1ca-min.jpg 2024-04-05 12:27:59 +01:00
erew123 241fa91473 Delete system/at_admin/3c6fde566d6a-min.jpg 2024-04-05 12:27:50 +01:00
erew123 2a5c8dd58a Add files via upload 2024-04-05 12:17:28 +01:00
erew123 2bfa10d7be Fix Windows 10 issue with path/environment. 2024-04-05 12:07:46 +01:00
erew123 3501e2e2f3 Fix crunker bug over networks
Crunker had an update to resolve bad performance over networks. This would affect only the TTS Generator when used remotely from AllTalk.
2024-04-05 10:26:33 +01:00
erew123 679e3a0982 Update atsetup.bat
encapsulate SET path
2024-04-04 19:11:59 +01:00
erew123 35d05c7689 Add files via upload 2024-04-04 11:07:21 +01:00
erew123 084cc2d2a2 Add files via upload 2024-04-04 11:02:59 +01:00
erew123 a96c82ff01 Add files via upload 2024-04-04 10:58:35 +01:00
erew123 aa7ff1940a Add files via upload 2024-04-04 10:30:45 +01:00
erew123 58465ae14e Update Dockerfile 2024-04-04 10:25:33 +01:00
erew123 2f49f61645 Add files via upload 2024-04-04 10:16:30 +01:00
erew123 58a70caebc Update README.md 2024-04-04 01:58:04 +01:00
erew123 d0d470db0f Update README.md 2024-04-04 01:57:02 +01:00
erew123 068fc72346 Update README.md 2024-04-04 01:55:10 +01:00
erew123 fc5c8c748f Standalone reminder re scripts 2024-04-04 00:39:20 +01:00
erew123 24f86d08b7 Update README.md 2024-04-03 11:10:40 +01:00
erew123 99e402664c Update feature_request.md 2024-04-02 16:57:21 +01:00
erew123 24cf9eae59 Update bug-report-support-request.md 2024-04-02 16:56:43 +01:00
erew123 18b1582d2a Fix curl being funny on re-apply requirements 2024-04-02 16:16:10 +01:00
erew123 96d9df9438 Update README.md 2024-04-02 16:13:26 +01:00
erew123 4ca156a032 Waning/Documentation messages
Added a routine to both atsetups to warn about paths with spaces in them.
Added notes to finetune to make certain aspects clearer
Changed a note in readme
2024-04-02 13:39:08 +01:00
erew123 5aecb5b7fd Spelling/Colour correction 2024-04-01 15:24:20 +01:00
erew123 63c308ff05 Fix wav file deletion display 2024-04-01 14:52:31 +01:00
erew123 e6e4b0b47f Merge pull request #156 from erew123/dev
Dev to main
2024-04-01 13:55:59 +01:00
erew123 bedc8148ad Update README.md 2024-04-01 13:52:32 +01:00
34 changed files with 3182 additions and 162 deletions

No files matched your search

@@ -1,6 +1,6 @@
---
name: Support request OR Bug report
about: Create a report to help us improve
name: Support Request/Issue
about: Use this to create a support request or report a bug/issue
title: ''
labels: ''
assignees: ''
+1
View File
@@ -0,0 +1 @@
blank_issues_enabled: false
+4 -1
View File
@@ -1,12 +1,15 @@
---
name: Feature request
about: Suggest an idea for this project
about: Use this to create a Feature request
title: ''
labels: ''
assignees: ''
---
**Please confirm you have read the current Features request list**
https://github.com/erew123/alltalk_tts/discussions/74
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+73
View File
@@ -0,0 +1,73 @@
name: 'Setting up docker'
inputs:
DOCKERHUB_USERNAME:
description: "Docker hub username"
required: true
DOCKERHUB_REPO_NAME:
description: "Docker hub repo name"
required: true
DOCKERHUB_TOKEN:
description: "Docker hub token"
required: true
runs:
using: "composite"
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: true
swap-storage: false
large-packages: false
- name: Read variables
shell: bash
run: |
source ./docker/variables.sh
for key in "${!ALLTALK_VARS[@]}"
do
echo "${key}=${ALLTALK_VARS[${key}]}"
echo "${key}=${ALLTALK_VARS[${key}]}" >> $GITHUB_ENV
done
- name: Extract version from Git Tag
shell: bash {0}
run: |
# Use the git tag if existing, otherwise 'latest':
DOCKER_TAG=$( echo "${{ github.ref }}" | grep -q tags | cut -d'/' -f 3 )
if [ -z "${DOCKER_TAG}" ]; then
DOCKER_TAG="latest"
fi
echo "Using DOCKER_TAG=${DOCKER_TAG}"
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
- name: Extract Docker Hub User and Repo Name
shell: bash
env:
DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }}
DOCKERHUB_REPO_NAME: ${{ inputs.DOCKERHUB_REPO_NAME }}
run: |
if [ -n "${DOCKERHUB_USERNAME}" ]; then
echo "Using Github repository variable 'DOCKERHUB_USERNAME' as Docker hub username with value: '${DOCKERHUB_USERNAME}'"
echo "DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME}" >> $GITHUB_ENV
else
echo "Using Github repository name as Docker hub username"
echo "DOCKERHUB_USERNAME=$(echo ${{ github.repository }} | cut -d'/' -f 1)" >> $GITHUB_ENV
fi
if [ -n "${DOCKERHUB_REPO_NAME}" ]; then
echo "Using Github repository variable 'DOCKERHUB_REPO_NAME' as Docker hub repo name with value: '${DOCKERHUB_REPO_NAME}'"
echo "DOCKERHUB_REPO_NAME=${DOCKERHUB_REPO_NAME}" >> $GITHUB_ENV
else
echo "Using Github repository name as Docker hub repo name"
echo "DOCKERHUB_REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f 2)" >> $GITHUB_ENV
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ inputs.DOCKERHUB_USERNAME }}
password: ${{ inputs.DOCKERHUB_TOKEN }}
+124
View File
@@ -0,0 +1,124 @@
name: Publish Docker v2
on:
workflow_dispatch:
release:
types: [ published ]
push:
branches:
- 'alltalkbeta'
tags:
- 'v*'
# Limit the concurrency of entire workflow runs for a specific branch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_base_environment_docker_image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup docker
uses: ./.github/actions/docker-setup
with:
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
DOCKERHUB_REPO_NAME: ${{ vars.DOCKERHUB_REPO_NAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}_environment
tags: |
# Use sematic versioning on push tag event:
type=semver,pattern={{version}}
# set latest tag for main and alltalkbeta branch:
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.ref == format('refs/heads/{0}', 'alltalkbeta') }}
- uses: dorny/paths-filter@v3
id: changes
with:
base: 'alltalkbeta'
filters: |
docker-base:
- 'docker/variables.sh'
- 'docker/base/Dockerfile'
docker-workflow:
- '.github/workflows/publish-docker*.yml'
- name: Build and push base Docker image
if: |
steps.changes.outputs.docker-base == 'true' ||
steps.changes.outputs.docker-workflow == 'true' ||
github.event_name == 'release' ||
(github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
uses: docker/build-push-action@v6
with:
context: ./docker/base
file: ./docker/base/Dockerfile
platforms: "linux/amd64"
push: true
build-args: |
CUDA_VERSION=${{ env.CUDA_VERSION }}
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}_environment:buildcache
cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}_environment:buildcache,mode=max
build_main_docker_image:
needs: build_base_environment_docker_image
runs-on: ubuntu-latest
strategy:
matrix:
tts: [ xtts, vits, piper ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup docker
uses: ./.github/actions/docker-setup
with:
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
DOCKERHUB_REPO_NAME: ${{ vars.DOCKERHUB_REPO_NAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}
flavor: |
suffix=-${{ matrix.tts }},onlatest=true
tags: |
# Use sematic versioning on push tag event:
type=semver,pattern={{version}}
# set latest tag for main and alltalkbeta branch:
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.ref == format('refs/heads/{0}', 'alltalkbeta') }}
- name: Build and push base Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: "linux/amd64"
push: true
build-args: |
TTS_MODEL=${{ matrix.tts }}
ALLTALK_DIR=${{ env.ALLTALK_DIR }}
DEEPSPEED_VERSION=${{ env.DEEPSPEED_VERSION }}
DOCKER_TAG=${{ env.DOCKER_TAG }}
DOCKER_REPOSITORY=${{ env.DOCKERHUB_USERNAME }}/
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}:buildcache-${{ matrix.tts }}
cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}:buildcache-${{ matrix.tts }},mode=max
+3 -3
View File
@@ -1,8 +1,8 @@
name: Publish Docker image
name: Publish Docker image (main branch)
on:
push:
branches: [main]
# push:
# branches: [main]
release:
types: [published]
workflow_dispatch:
+53
View File
@@ -0,0 +1,53 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python CI
on: [push, pull_request]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11.9
uses: actions/setup-python@v3
if: ${{ hashFiles('./test') != '' }}
with:
python-version: "3.11.9"
- name: Install dependencies
if: ${{ hashFiles('./test') != '' }}
run: |
python -m pip install --upgrade pip
if [ -f system/requirements/requirements_unit_test.txt ]; then
pip install -r system/requirements/requirements_unit_test.txt;
fi
- name: Test with pytest
if: ${{ hashFiles('./test') != '' }}
run: |
pytest test --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@v0.6.0
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: junit/test-results.xml
# (Optional) Add a summary of the results at the top of the report
summary: true
# (Optional) Select which results should be included in the report.
# Follows the same syntax as `pytest -r`
display-options: fEX
# (Optional) Fail the workflow if no JUnit XML was found.
fail-on-empty: false
# (Optional) Title of the test results section in the workflow summary
title: Test results
+11 -3
View File
@@ -1,12 +1,20 @@
FROM ubuntu:22.04
FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
ENV HOST 0.0.0.0
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y git build-essential portaudio19-dev \
python3 python3-pip gcc wget \
ocl-icd-opencl-dev opencl-headers clinfo \
libclblast-dev libopenblas-dev libaio-dev \
&& mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd \
&& ln -s /usr/bin/python3 /usr/bin/python
WORKDIR /app
ENV CUDA_DOCKER_ARCH=all
COPY system/requirements/requirements_docker.txt system/requirements/requirements_docker.txt
RUN pip install --no-cache-dir --no-deps -r system/requirements/requirements_docker.txt && \
pip install --no-cache-dir deepspeed
COPY . .
RUN pip install --no-cache-dir -r requirements_other.txt
EXPOSE 7851
EXPOSE 7851 7852
RUN chmod +x launch.sh
ENTRYPOINT ["sh", "-c", "./launch.sh"]
+56 -47
View File
@@ -1,5 +1,13 @@
# AllTalk TTS
AllTalk is an updated version of the Coqui_tts extension for Text Generation web UI. Features include:
## AllTalk version 2
# [Click here to go to AllTalk Version 2](https://github.com/erew123/alltalk_tts/tree/alltalkbeta)
AllTalk v2 significantly enhances v1, introducing new features while addressing many previous issues. Although still evolving, v2 offers a stable build and is the recommended version for most users as this is where update and development work is now focused.
## ⚠️ AllTalk v1 - Everything BELOW this point is for AllTalk v1⚠️
AllTalk version 1 is an updated version of the Coqui_tts extension for Text Generation web UI. Features include:
- **Can be run as a** [standalone application](https://github.com/erew123/alltalk_tts/#-quick-setup-text-generation-webui--standalone-installation) **or part of :**
- **Text-generation-webui** [link](https://github.com/oobabooga/text-generation-webui)
@@ -57,9 +65,13 @@ If AllTalk has been helpful to you, consider showing your support through a dona
---
### 🟩 Quick Setup (Text-generation-webui & Standalone Installation)
# [Click here if you want AllTalk Version 2](https://github.com/erew123/alltalk_tts/tree/alltalkbeta)
Quick setup scripts are available for users on Windows 10/11 and Linux. Instructional videos for both setup processes are linked below.
## ⚠️ Everything on this page is for AllTalk v1 not AllTalk v2 ⚠️
### 🟩 Quick Setup AllTalk Version 1 (Text-generation-webui & Standalone Installation)
AllTalk version 1 - Quick setup scripts are available for users on Windows 10/11 and Linux. Instructional videos for both setup processes are linked below.
- Ensure that **Git** is installed on your system as it is required for cloning the repository. If you do not have Git installed, visit [**Git's official website**](https://git-scm.com/downloads) to download and install it.
- Windows users must install C++ development tools for Python to compile Python packages. Detailed information and a link to these tools can be found in the help section [**Windows & Python requirements for compiling packages**](https://github.com/erew123/alltalk_tts#-help-with-problems).
@@ -126,7 +138,7 @@ To perform a Standalone installation of AllTalk:
> If you're unfamiliar with Python environments and wish to learn more, consider reviewing **Understanding Python Environments Simplified** in the Help section.
> **Important**: Do not use dashes or spaces in your folder path (e.g. avoid `/my folder-is-this/alltalk_tts-main`) as this causes issues with Python.
> **Important**: Do not use spaces in your folder path (e.g. avoid `/my folder-is-this/alltalk_tts-main`) as this causes issues with Python & Conda.
</details>
@@ -143,11 +155,11 @@ As for Google Colab, there is partial compatibility with AllTalk, though with so
---
### 🟩 Manual Installation - As part of Text generation web UI (inc. macOSX)
### 🟩 Manual Installation AllTalk Version 1 - As part of Text generation web UI (inc. macOSX)
<details>
<summary>MANUAL INSTALLATION - Text-Generation-webui</summary>
### Manual Installation for Text Generation Web UI
### Manual Installation AllTalk Version 1 for Text Generation Web UI
If you're using a Mac or prefer a manual installation for any other reason, please follow the steps below. This guide is compatible with the current release of Text Generation Web UI as of December 2023. Consider updating your installation if it's been a while, [update instructions here](https://github.com/oobabooga/text-generation-webui?tab=readme-ov-file#how-to-install).
@@ -177,11 +189,9 @@ If you're using a Mac or prefer a manual installation for any other reason, plea
- `cd alltalk_tts`
6. **Install Required Dependencies**:
- Install dependencies based on your machine type:
- For Nvidia graphics card machines:
- `pip install -r requirements_nvidia.txt`
- For other machines (mac, AMD, etc.):
- `pip install -r requirements_other.txt`
- Install dependencies for your machine type:
- For Windows: `pip install -r system\requirements\requirements_textgen.txt`
- For Linux/Mac: `pip install -r system/requirements/requirements_textgen.txt`
7. **Optional DeepSpeed Installation**:
- If you're using an Nvidia graphics card on Linux or Windows and wish to install **DeepSpeed**, follow the instructions [here](https://github.com/erew123/alltalk_tts?#-deepspeed-installation-options).
@@ -240,7 +250,7 @@ Support for custom Python environments is limted. Please read **Custom Python en
To run AllTalk as a standalone application with a custom Python environment, ensure you install AllTalk's requirements into the environment of your choice. The instructions provided are generalized due to the variety of potential Python environments.
- **Python Compatibility**: The TTS engine requires Python **3.9.x** to **3.11.x**. AllTalk is tested with Python **3.11.x**. [See TTS Engine details](https://pypi.org/project/TTS/).
- **Path Names**: Avoid spaces and dashes `-` in path names as this can cause issues.
- **Path Names**: Avoid spaces in path names as this can cause issues.
- **Custom Python Environments**: If encountering issues potentially related to a custom environment, consider testing AllTalk with the quick setup standalone method that builds its own environment.
#### Quick Overview of Python Environments
@@ -271,10 +281,8 @@ To run AllTalk as a standalone application with a custom Python environment, ens
5. **Install Requirements**:
- Install dependencies based on your machine type:
- For Nvidia graphics card machines:
- `pip install -r requirements_nvidia.txt`
- For other machines (mac, AMD, etc.):
- `pip install -r requirements_other.txt`
- For Windows: `pip install -r system\requirements\requirements_standalone.txt`
- For Linux/Mac: `pip install -r system/requirements/requirements_standalone.txt`
6. **Start AllTalk**:
- Run AllTalk with the following:
@@ -390,12 +398,18 @@ The update process closely mirrors the installation steps. Follow these to ensur
- **For Linux/Mac**:
- `pip install -r system/requirements/requirements_textgen.txt`
5. **DeepSpeed Requirements**:
- If Text-gen-webui is using a new version of PyTorch, you may need to uninstall and update your DeepSpeed version.
- Use AllTalks diagnostics or start-up menu to identify your version of PyTorch.
<br><br>
</details>
<details>
<summary>UPDATING - Standalone Application</summary>
<br>
If you installed from a ZIP file, you cannot use a `git pull` to update, as noted in the Quick Setup instructions.
For Standalone Application users, here's how to update your setup:
1. **Open a Command Prompt/Terminal**:
@@ -421,7 +435,7 @@ For Standalone Application users, here's how to update your setup:
- `pip install -r system\requirements\requirements_standalone.txt`
- **For Linux/Mac**:
- `pip install -r system/requirements/requirements_standalone.txt`
<br><br>
</details>
### 🟪 Resolving Update Issues
@@ -429,43 +443,23 @@ For Standalone Application users, here's how to update your setup:
If you encounter problems during or after an update, following these steps can help resolve the issue by refreshing your installation while preserving your data:
<details>
<summary>RESOLVING - Text-Generation-webui</summary><br>
<summary>RESOLVING - Updates</summary><br>
The process involves renaming your existing `alltalk_tts` directory, setting up a fresh instance, and then migrating your data:
1. **Rename Existing Directory**:
- First, rename your current `alltalk_tts` folder to back it up, e.g., `alltalk_tts.old`. This preserves any existing data.
- First, rename your current `alltalk_tts` folder to keep it safe e.g. `alltalk_tts.old`. This preserves any existing data.
2. **Open a Console/Terminal**:
- Navigate to the Text-generation-webui directory and start the Python environment appropriate for your operating system:
- `cd text-generation-webui`
- Then use one of the following commands based on your OS:
- Windows: `cmd_windows.bat`
- Linux: `./cmd_linux.sh`
- macOS: `cmd_macos.sh`
- WSL (Windows Subsystem for Linux): `cmd_wsl.bat`<br><br>
2. **Follow the Quick Setup instructions**:
- You will now follow the **Quick Setup** instructions, performing the `git clone https://github.com/erew123/alltalk_tts` to pull down a new copy of AllTalk and install the requirements.
> If you're not familiar with Python environments, see **Understanding Python Environments Simplified** in the Help section for more info.
3. **Clone the AllTalk TTS Repository**:
- Move into the `extensions` directory and clone a fresh copy of `alltalk_tts`:
- `cd extensions`
- `git clone https://github.com/erew123/alltalk_tts`
3. **Migrate Your Data**:
- **Before** starting the AllTalk, transfer the `models`, `voices`, `outputs` folders and also `confignew.json` from `alltalk_tts.old` to the new `alltalk_tts` directory. This action preserves your voice history and prevents the need to re-download the model.
4. **Install Requirements**:
- Navigate to the newly cloned `alltalk_tts` directory and install the necessary dependencies for your system:
- `cd alltalk_tts`
- Depending on your machine's OS, install the required dependencies using pip:
- **For Windows Machines**:
- `pip install -r system\requirements\requirements_textgen.txt`
- **For Linux/Mac**:
- `pip install -r system/requirements/requirements_textgen.txt`
5. **Migrate Your Data**:
- Before starting the application, transfer the `models`, `voices`, and `outputs` folders from `alltalk_tts.old` to the new `alltalk_tts` directory. This action preserves your voice history and prevents the need to re-download the model.
You're now ready to launch Text-generation-webui. Note that you may need to reapply any previously saved configuration changes through the configuration page.
4) **Launch AllTalk**
- You're now ready to launch AllTalk and check it works correctly.
6. **Final Step**:
- Once you've verified that everything is working as expected and you're satisfied with the setup, feel free to delete the `alltalk_tts.old` directory to free up space.
@@ -732,7 +726,7 @@ When a Python environment starts up, it changes the command prompt to show the P
<details>
<summary>🟨 Standalone Install - start_{youros}.xx opens and closes instantly and AllTalk doesnt start</summary><br>
This is more than likely caused by having a `-` in your folder path e.g. `c:\myfiles\alltalk_tts-main`. In this circumstance you would be best renaming the folder to remove the `-` from its name e.g. `c:\myfiles\alltalk_tts`, delete the `alltalk_environment` folder and `start_alltalk.bat` or `start_alltalk.sh` and then re-run `atsetup` to re-create the environment and startup files.
This is more than likely caused by having a space ` ` in your folder path e.g. `c:\program files\alltalk_tts`. In this circumstance you would be best moving the folder to a path without a space e.g. `c:\myfiles\alltalk_tts`. You would have to delete the `alltalk_environment` folder and `start_alltalk.bat` or `start_alltalk.sh` and then re-run `atsetup` to re-create the environment and startup files.
</details>
<details>
<summary>🟨 I think AllTalks requirements file has installed something another extension doesn't like</summary><br>
@@ -960,6 +954,12 @@ Depending on which of your Nvidia GPU's is the more powerful one, you can change
This is a long standing issue with Mozilla & Firefox and one I am unable to resolve as Mozilla have not resolved the issue with Firefox. The solution is to use another web browser if you want to use Streaming audio. For details of my prior invesitigation please look at this [ticket](https://github.com/erew123/alltalk_tts/issues/143)
</details>
<details>
<summary>🟨 Hindi Support - Not working or issues</summary><br>
Hindi support does not officially exist according to Coqui. Ive added a limited Hindi support at this time, however, It only works with API TTS method and Im sure there will be issues. [ticket](https://github.com/erew123/alltalk_tts/issues/178)
</details>
### Application Specific Issues
<details>
@@ -1013,7 +1013,7 @@ If you wish to try out the XTTS version 2.0.3 model and see if it works better,
### ⚫ Finetuning a model
If you have a voice that the model doesnt quite reproduce correctly, or indeed you just want to improve the reproduced voice, then finetuning is a way to train your "XTTSv2 local" model **(stored in `/alltalk_tts/models/xxxxx/`)** on a specific voice. For this you will need:
- An Nvidia graphics card. (Please see the help section [note](https://github.com/erew123/alltalk_tts/edit/main/README.md#performance-and-compatibility-issues) if you have multiple Nvidia GPU's).
- An Nvidia graphics card. (Please see the help section [note](https://github.com/erew123/alltalk_tts/edit/main/README.md#performance-and-compatibility-issues) if you have multiple Nvidia GPU's). Preferably 12GB+ VRAM on Windows. Minimum 16GB VRAM on Linux.
- 18GB of disk space free (most of this is used temporarily)
- At least 2 minutes of good quality speech from your chosen speaker in mp3, wav or flacc format, in one or more files (have tested as far as 20 minutes worth of audio).
- As a side note, many people seem to think that the Whisper v2 model (used on Step 1) is giving better results at generating training datasets, so you may prefer to try that, as opposed to the Whisper 3 model.
@@ -1175,6 +1175,14 @@ At the end of the finetune process, you will have an option to `Compact and move
If you've compacted and moved your model, its highly unlikely you would want to keep that data, however the choice is there to keep it if you wish. It will be between 5-10GB in size, so most people will want to delete it.
#### ⚫ I have deeper questions about training the XTTS model, where can I find more information?
If you have deeper questions about the XTTS model, its capabilites, the training process etc, anything thats not covered within the above text or the interface of `finetune.py`, please use the following links to research Coqui's documentation on the XTTS model.
- https://docs.coqui.ai/en/latest/models/xtts.html
- https://github.com/coqui-ai/TTS
- https://github.com/coqui-ai/TTS/discussions
---
### ⬜ AllTalk TTS Generator
@@ -1401,6 +1409,7 @@ Example:
`en` English<br>
`fr` French<br>
`de` German<br>
`hi` Hindi (Please see this re Hindi support, which is very limited https://github.com/erew123/alltalk_tts/issues/178) <br>
`hu` Hungarian<br>
`it` Italian<br>
`ja` Japanese<br>
+27 -6
View File
@@ -1,7 +1,7 @@
@echo off
cd /D "%~dp0"
set PATH=%PATH%;%SystemRoot%\system32
setlocal enabledelayedexpansion
@set "PATH=%PATH%;%SystemRoot%\system32"
:: Generate the ESC character
for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
@@ -25,6 +25,15 @@ set "L_CYAN=%ESC%[96m"
set "L_WHITE=%ESC%[97m"
set "RESET=%ESC%[0m"
echo "%CD%"| findstr /C:" " >nul && echo. && echo %L_BLUE%ALLTALK WINDOWS SETUP UTILITY%RESET% && echo. && echo. && echo You are trying to install AllTalk in a folder that has a space in the folder path e.g. && echo. && echo C:\%L_RED%program files%RESET%\alltalk_tts && echo. && echo This causes errors with Conda and Python scripts. Please follow this link for reference: && echo. && echo %L_CYAN%https://docs.anaconda.com/free/working-with-conda/reference/faq/#installing-anaconda%RESET% && echo. && echo Please use a folder path that has no spaces in it e.g. && echo. && echo C:\myfiles\alltalk_tts\ && echo. && echo. && pause && goto :end
@rem Check for special characters in installation path
set "SPCHARMESSAGE="WARNING: Special characters were detected in the installation path!" " This can cause the installation to fail!""
echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~]" >nul && (
call :PrintBigMessage %SPCHARMESSAGE%
)
set SPCHARMESSAGE=
@rem Check if curl is available
curl --version >nul 2>&1
if "%ERRORLEVEL%" NEQ "0" (
@@ -120,7 +129,7 @@ if "%StandaloneOption%"=="3" goto STReapplyrequirements
if "%StandaloneOption%"=="4" goto STDeleteCustomStandalone
if "%StandaloneOption%"=="5" goto STPurgepipcache
if "%StandaloneOption%"=="8" goto GenerateDiagsStandalone
if "%StandaloneOption%"=="9" goto End
if "%StandaloneOption%"=="9" goto EndStandalone
goto StandaloneMenu
:InstallNvidiaTextGen
@@ -128,6 +137,8 @@ pip install -r system\requirements\requirements_textgen.txt
if %ERRORLEVEL% neq 0 (
echo.
echo There was an error installing the requirements.
echo Have you started your Text-gen-webui Python environment
echo with cmd_{yourOS} before running atsetup.bat?
echo Press any key to return to the menu.
echo.
pause
@@ -383,7 +394,7 @@ echo Downloading and installing PyTorch. This step can take a long time
echo depending on your internet connection and hard drive speed. Please
echo be patient.
echo.
pip install torch>=2.2.1+cu121 torchaudio>=2.2.1+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
pip install torch==2.2.2+cu121 torchaudio>=2.2.2+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
echo Installing other requirements.
echo.
pip install -r system\requirements\requirements_standalone.txt
@@ -524,11 +535,11 @@ echo Downloading and installing PyTorch. This step can take a long time
echo depending on your internet connection and hard drive speed. Please
echo be patient.
echo.
pip install torch>=2.2.1+cu121 torchaudio>=2.2.1+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
pip install torch==2.2.2+cu121 torchaudio>=2.2.2+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
echo Installing other requirements.
echo.
pip install -r system\requirements\requirements_standalone.txt
curl -LO https://github.com/erew123/alltalk_tts/releases/download/DeepSpeed-14.0/deepspeed-0.14.0+ce78a63-cp311-cp311-win_amd64.whl
C:/Windows/system32/curl.exe -LO https://github.com/erew123/alltalk_tts/releases/download/DeepSpeed-14.0/deepspeed-0.14.0+ce78a63-cp311-cp311-win_amd64.whl
echo Installing DeepSpeed...
pip install deepspeed-0.14.0+ce78a63-cp311-cp311-win_amd64.whl
del deepspeed-0.14.0+ce78a63-cp311-cp311-win_amd64.whl
@@ -633,6 +644,16 @@ Echo.
pause
goto StandaloneMenu
:EndStandalone
echo Exiting AllTalk Setup Utility...
echo.
Echo Remember, after installation you can....
Echo Run %L_YELLOW%start_alltalk.bat%RESET% to start AllTalk.
Echo Run %L_YELLOW%start_finetune.bat%RESET% to start Finetuning.
Echo Run %L_YELLOW%start_environment.bat%RESET% to start the AllTalk Python environment.
Echo.
exit /b
:End
echo Exiting AllTalk Setup Utility...
exit /b
+36 -2
View File
@@ -28,6 +28,40 @@ check_curl() {
fi
}
# Check if the current directory path contains a space
containsSpace=false
currentPath=$(pwd)
if echo "$currentPath" | grep -q ' '; then
containsSpace=true
fi
if [ "$containsSpace" = true ]; then
echo
echo -e " ${L_BLUE}ALLTALK LINUX SETUP UTILITY${NC}"
echo
echo
echo -e " You are trying to install AllTalk in a folder that has a space in the"
echo -e " folder path e.g."
echo
echo -e " /home/${L_RED}program files${NC}/alltalk_tts"
echo
echo -e " This causes errors with Conda and Python scripts. Please follow this"
echo -e " link for reference:"
echo
echo -e " ${L_CYAN}https://docs.anaconda.com/free/working-with-conda/reference/faq/#installing-anaconda${NC}"
echo
echo -e " Please use a folder path that has no spaces in it e.g."
echo
echo -e " /home/myfiles/alltalk_tts/"
echo
echo
read -p "Press Enter to continue..."
exit 1
else
# Continue with the main menu
echo "Continue with the main menu."
fi
# Main Menu
main_menu() {
while true; do
@@ -291,7 +325,7 @@ install_custom_standalone() {
echo " Downloading and installing PyTorch. This step can take a long time"
echo " depending on your internet connection and hard drive speed. Please"
echo " be patient."
pip install torch>=2.2.1+cu121 torchaudio>=2.2.1+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu1
pip install torch==2.2.1+cu121 torchaudio==2.2.1+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
echo
echo " Installing additional requirements."
echo
@@ -469,7 +503,7 @@ reapply_standalone() {
echo " Downloading and installing PyTorch. This step can take a long time"
echo " depending on your internet connection and hard drive speed. Please"
echo " be patient."
pip install torch>=2.2.1+cu121 torchaudio>=2.2.1+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu1
pip install torch>=2.2.1+cu121 torchaudio>=2.2.1+cu121 --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
echo
echo " Installing additional requirements."
echo
+15 -1
View File
@@ -1,13 +1,27 @@
version: '3.8'
services:
alltalk-tts:
image: erew123/alltalk_tts:cpu
image: ${IMAGE:-alltalk:v1-9c}
restart: unless-stopped
ports:
- "7851:7851"
- "7852:7852"
volumes:
- ./outputs:/app/outputs/
- ./models:/app/models/
- ./voices:/app/voices/
- ./finetune/put-voice-samples-in-here:/app/finetune/put-voice-samples-in-here
- ./dockerconfig.json:/app/confignew.json
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:7851/api/ready"]
interval: 1m30s
timeout: 30s
retries: 5
start_period: 30s
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [ gpu ]
+220 -58
View File
@@ -291,12 +291,12 @@ def create_temporary_file(folder, suffix=".wav"):
unique_filename = f"custom_tempfile_{int(time.time())}_{random.randint(1, 1000)}{suffix}"
return os.path.join(folder, unique_filename)
def format_audio_list(target_language, whisper_model, out_path, eval_split_number, gradio_progress=progress):
def format_audio_list(target_language, whisper_model, out_path, eval_split_number, speaker_name_input, gradio_progress=progress):
pfc_check_fail()
audio_files = [os.path.join(audio_folder, file) for file in os.listdir(audio_folder) if file.endswith(('.mp3', '.flac', '.wav'))]
buffer=0.2
eval_percentage = eval_split_number / 100.0
speaker_name="coqui"
speaker_name=speaker_name_input
audio_total_size = 0
os.makedirs(out_path, exist_ok=True)
temp_folder = os.path.join(out_path, "temp") # Update with your folder name
@@ -533,7 +533,7 @@ def basemodel_or_finetunedmodel_choice(value):
elif value == "Existing finetuned model":
basemodel_or_finetunedmodel = False
def train_gpt(language, num_epochs, batch_size, grad_acumm, train_csv, eval_csv, output_path, max_audio_length=255995):
def train_gpt(language, num_epochs, batch_size, grad_acumm, train_csv, eval_csv, learning_rate, output_path, max_audio_length=255995):
pfc_check_fail()
# Logging parameters
RUN_NAME = "XTTS_FT"
@@ -657,7 +657,7 @@ def train_gpt(language, num_epochs, batch_size, grad_acumm, train_csv, eval_csv,
optimizer="AdamW",
optimizer_wd_only_on_weights=OPTIMIZER_WD_ONLY_ON_WEIGHTS,
optimizer_params={"betas": [0.9, 0.96], "eps": 1e-8, "weight_decay": 1e-2},
lr=5e-06, # learning rate
lr=learning_rate, # learning rate
lr_scheduler="MultiStepLR",
# it was adjusted accordly for the new step scheme
lr_scheduler_params={"milestones": [50000 * 18, 150000 * 18, 300000 * 18], "gamma": 0.5, "last_epoch": -1},
@@ -735,6 +735,9 @@ def load_model(xtts_checkpoint, xtts_config, xtts_vocab):
config.load_json(xtts_config)
XTTS_MODEL = Xtts.init_from_config(config)
print("[FINETUNE] \033[94mStarting Step 3\033[0m Loading XTTS model!")
print(xtts_checkpoint)
print(xtts_vocab)
print(xtts_speakers_pth)
XTTS_MODEL.load_checkpoint(config, checkpoint_path=xtts_checkpoint, vocab_path=xtts_vocab, use_deepspeed=False, speaker_file_path=xtts_speakers_pth)
if torch.cuda.is_available():
XTTS_MODEL.cuda()
@@ -773,18 +776,22 @@ def get_available_voices(minimum_size_kb=1200):
]
return sorted([str(file) for file in voice_files]) # Return full path as string
def find_best_models(directory):
"""Find files named 'best_model.pth' in the given directory."""
return [str(file) for file in Path(directory).rglob("best_model.pth")]
def find_models(directory, extension):
"""Find files with a specific extension in the given directory."""
return [file for file in Path(directory).rglob(f"*.{extension}")]
return [str(file) for file in Path(directory).rglob(f"*.{extension}")]
def find_jsons(directory, filename):
"""Find files with a specific filename in the given directory."""
return list(Path(directory).rglob(filename))
return [str(file) for file in Path(directory).rglob(filename)]
# Your main directory
main_directory = Path(this_dir) / "finetune" / "tmp-trn"
# XTTS checkpoint files (*.pth)
xtts_checkpoint_files = find_models(main_directory, "pth")
# XTTS checkpoint files (best_model.pth)
xtts_checkpoint_files = find_best_models(main_directory)
# XTTS config files (config.json)
xtts_config_files = find_jsons(main_directory, "config.json")
# XTTS vocab files (vocab.json)
@@ -800,48 +807,49 @@ def find_latest_best_model(folder_path):
latest_file = max(files, key=os.path.getctime, default=None)
return latest_file
def compact_model():
def compact_model(xtts_checkpoint_copy):
this_dir = Path(__file__).parent.resolve()
best_model_path_str = find_latest_best_model(this_dir / "finetune" / "tmp-trn" / "training")
print("THIS DIR:", this_dir)
best_model_path_str = str(xtts_checkpoint_copy) # Convert to string
print("best_model_path_str", best_model_path_str)
# Check if the best model file exists
if best_model_path_str is None:
if not best_model_path_str:
print("[FINETUNE] No trained model was found.")
return "No trained model was found."
# Convert model_path_str to Path
best_model_path = Path(best_model_path_str)
print(f"[FINETUNE] Best model path: {best_model_path_str}")
# Attempt to load the model
try:
checkpoint = torch.load(best_model_path, map_location=torch.device("cpu"))
checkpoint = torch.load(best_model_path_str, map_location=torch.device("cpu"))
print(f"[FINETUNE] Checkpoint loaded: {best_model_path_str}")
except Exception as e:
print("[FINETUNE] Error loading checkpoint:", e)
raise
del checkpoint["optimizer"]
for key in list(checkpoint["model"].keys()):
if "dvae" in key:
del checkpoint["model"][key]
# Define the target directory
target_dir = this_dir / "models" / "trainedmodel"
# Create the target directory if it doesn't exist
target_dir.mkdir(parents=True, exist_ok=True)
del checkpoint["optimizer"]
for key in list(checkpoint["model"].keys()):
if "dvae" in key:
del checkpoint["model"][key]
# Save the modified checkpoint in the target directory
torch.save(checkpoint, target_dir / "model.pth")
torch.save(checkpoint, str(target_dir / "model.pth")) # Convert to string
# Specify the files you want to copy
files_to_copy = ["vocab.json", "config.json", "dvae.pth", "mel_stats.pth","speakers_xtts.pth", ]
files_to_copy = ["vocab.json", "config.json", "speakers_xtts.pth", "mel_stats.pth", "dvae.pth"]
for file_name in files_to_copy:
src_path = this_dir / base_path / base_model_path / file_name
dest_path = target_dir / file_name
shutil.copy(str(src_path), str(dest_path))
shutil.copy(str(src_path), str(dest_path)) # Convert to string
source_wavs_dir = this_dir / "finetune" / "tmp-trn" / "wavs"
target_wavs_dir = target_dir / "wavs"
@@ -852,16 +860,17 @@ def compact_model():
# Check if it's a file and larger than 1000 KB
if file_path.is_file() and file_path.stat().st_size > 1000 * 1024:
# Copy the file to the target directory
shutil.copy(str(file_path), str(target_wavs_dir / file_path.name))
shutil.copy(str(file_path), str(target_wavs_dir / file_path.name)) # Convert to string
print("[FINETUNE] Model copied to '/models/trainedmodel/'")
return "Model copied to '/models/trainedmodel/'"
def compact_lastfinetuned_model():
def compact_lastfinetuned_model(xtts_checkpoint_copy):
this_dir = Path(__file__).parent.resolve()
best_model_path_str = find_latest_best_model(this_dir / "finetune" / "tmp-trn" / "training")
best_model_path_str = xtts_checkpoint_copy
print(f"[FINETUNE] Best model path: {best_model_path_str}")
# Check if the best model file exists
if best_model_path_str is None:
@@ -880,21 +889,21 @@ def compact_lastfinetuned_model():
del checkpoint["optimizer"]
for key in list(checkpoint["model"].keys()):
if "dvae" in key:
del checkpoint["model"][key]
# Define the target directory
target_dir = this_dir / "models" / "lastfinetuned"
# Create the target directory if it doesn't exist
target_dir.mkdir(parents=True, exist_ok=True)
for key in list(checkpoint["model"].keys()):
if "dvae" in key:
del checkpoint["model"][key]
# Save the modified checkpoint in the target directory
torch.save(checkpoint, target_dir / "model.pth")
# Specify the files you want to copy
files_to_copy = ["vocab.json", "config.json", "dvae.pth", "mel_stats.pth", "speakers_xtts.pth",]
files_to_copy = ["vocab.json", "config.json", "speakers_xtts.pth", "mel_stats.pth", "dvae.pth",]
for file_name in files_to_copy:
src_path = this_dir / base_path / base_model_path / file_name
@@ -916,15 +925,16 @@ def compact_lastfinetuned_model():
return "Model copied to '/models/lastfinetuned/'"
def compact_legacy_model():
def compact_custom_model(xtts_checkpoint_copy, folder_path):
this_dir = Path(__file__).parent.resolve()
best_model_path_str = os.path.join(this_dir, "finetune", "best_model.pth")
best_model_path_str = xtts_checkpoint_copy
print(f"[FINETUNE] Best model path: {best_model_path_str}")
# Check if the best model file exists
if not os.path.exists(best_model_path_str):
print("[FINETUNE] No model called best_model.pth was found in /finetune/")
return "No model called best_model.pth was found in /finetune/"
if best_model_path_str is None:
print("[FINETUNE] No trained model was found.")
return "No trained model was found."
# Convert model_path_str to Path
best_model_path = Path(best_model_path_str)
@@ -938,21 +948,41 @@ def compact_legacy_model():
del checkpoint["optimizer"]
for key in list(checkpoint["model"].keys()):
if "dvae" in key:
del checkpoint["model"][key]
# Define the target directory
target_dir = this_dir / "finetune"
target_dir = this_dir / "models" / folder_path
# Create the target directory if it doesn't exist
target_dir.mkdir(parents=True, exist_ok=True)
for key in list(checkpoint["model"].keys()):
if "dvae" in key:
del checkpoint["model"][key]
# Save the modified checkpoint in the target directory
torch.save(checkpoint, target_dir / "model.pth")
print("[FINETUNE] model.pth created in '/finetune/'")
return "model.pth created in '/finetune/'"
# Specify the files you want to copy
files_to_copy = ["vocab.json", "config.json", "speakers_xtts.pth", "mel_stats.pth", "dvae.pth",]
for file_name in files_to_copy:
src_path = this_dir / base_path / base_model_path / file_name
dest_path = target_dir / file_name
shutil.copy(str(src_path), str(dest_path))
source_wavs_dir = this_dir / "finetune" / "tmp-trn" / "wavs"
target_wavs_dir = target_dir / "wavs"
target_wavs_dir.mkdir(parents=True, exist_ok=True)
# Iterate through files in the source directory
for file_path in source_wavs_dir.iterdir():
# Check if it's a file and larger than 1000 KB
if file_path.is_file() and file_path.stat().st_size > 1000 * 1024:
# Copy the file to the target directory
shutil.copy(str(file_path), str(target_wavs_dir / file_path.name))
print("[FINETUNE] Model copied to '/models/",folder_path,"/")
return f"Model copied to '/models/{folder_path}/'"
def delete_training_data():
# Define the folder to be deleted
@@ -1264,6 +1294,9 @@ if __name__ == "__main__":
### 🟥 <u>Important Note - Windows - "UserWarning: huggingface_hub cache-system uses symlinks."</u>
◽ This error is caused by Huggingfaces download software downloading the Whisper model. If you get this error, please restart your Windows command prompt with "Run as Administrator" and restart finetuning.<br>
◽ This should only occur the 1st time it downloads the Whisper model. [Huggingface Reference here](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache#limitations)
### 🟥 <u>Important Note - Language support.</u>
◽ Although I have done my best to help automate this step, the Whisper model is not great with all languages and may fail to build your training data correctly. The Large-v3 may be better at certain languages.<br>
◽ You can find information about the Whisper model [here](https://github.com/openai/whisper?tab=readme-ov-file#available-models-and-languages) and you can find data about manually building training data [here](https://docs.coqui.ai/en/latest/formatting_your_dataset.html), as well as details below about the file structure this step performs.<br>
### 🟦 <u>What you need to do</u>
◽ Please read Coqui's guide on what makes a good dataset [here](https://docs.coqui.ai/en/latest/what_makes_a_good_dataset.html#what-makes-a-good-dataset)<br>
◽ Place your audio files in <span style="color: #3366ff;">{str(audio_folder)}</span>
@@ -1276,6 +1309,7 @@ if __name__ == "__main__":
◽ Whisper is making a best effort to find spoken audio and break it down into smaller audio files. The content of these audio files is then transcribed into CSV fles (which you can edit in Excel or similar).<br>
◽ These files (audio and CSV) are used at the next step to train the model "this is what the audio sounds like and these are the words being spoken".<br>
◽ If you wish to manually look at the CSV files before running the next step, you are welcome to do so and edit them as necessary. The greater the accuracy of the text the better the training will be.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ◽ <span style="color: #3366ff;">/alltalk_tts/finetune/tmp-trn/lang.txt</span> Contains a two digit langauage code e.g. `en`, `fr` etc.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ◽ <span style="color: #3366ff;">/alltalk_tts/finetune/tmp-trn/metadata_train.csv</span> Contains the list of wavs to text that will be used. This is what the model is trained with.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ◽ <span style="color: #3366ff;">/alltalk_tts/finetune/tmp-trn/metadata_eval.csv</span> Lists the evaluation wav to text, used to generate TTS while training and evaluate the quality of generated TTS to the original sample.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ◽ <span style="color: #3366ff;">/alltalk_tts/finetune/tmp-trn/wavs/</span> These are the wavs split out from your original training samples and match the contents of the CSV files.<br>
@@ -1334,6 +1368,11 @@ if __name__ == "__main__":
maximum=95, # Maximum value
step=1, # Increment step
)
speaker_name_input = gr.Textbox(
label="The name of the speaker/person you are training",
value="personsname",
visible=True,
)
progress_data = gr.Label(
label="Progress:"
)
@@ -1345,14 +1384,15 @@ if __name__ == "__main__":
prompt_compute_btn = gr.Button(value="Step 1 - Create dataset")
def preprocess_dataset(language, whisper_model, out_path, eval_split_number, progress=gr.Progress(track_tqdm=True)):
def preprocess_dataset(language, whisper_model, out_path, eval_split_number, speaker_name_input, progress=gr.Progress(track_tqdm=True)):
clear_gpu_cache()
test_for_audio_files = [file for file in os.listdir(audio_folder) if any(file.lower().endswith(ext) for ext in ['.wav', '.mp3', '.flac'])]
if not test_for_audio_files:
return "I cannot find any mp3, wav or flac files in the folder called 'put-voice-samples-in-here'", "", ""
else:
try:
train_meta, eval_meta, audio_total_size = format_audio_list(target_language=language, whisper_model=whisper_model, out_path=out_path, eval_split_number=eval_split_number, gradio_progress=progress)
train_meta, eval_meta, audio_total_size = format_audio_list(target_language=language, whisper_model=whisper_model, out_path=out_path, eval_split_number=eval_split_number, speaker_name_input=speaker_name_input, gradio_progress=progress)
except:
traceback.print_exc()
error = traceback.format_exc()
@@ -1373,10 +1413,12 @@ if __name__ == "__main__":
#### GRADIO STEP 2 ####
#######################
with gr.Tab("💻 Step 2 - Training"):
with gr.Tab("Training"):
gr.Markdown(
f"""
### 💻 <u>Training</u><br>
### 🟥 <u>Important Note - Language support.</u>
◽ If this step is failing/erroring you may wish to check your training data was created correctly (Detailed in Step 1), confirming that wav files have been generated and your `metadata_train.csv` and `metadata_eval.csv` files have been populated.<br>
### 🟦 <u>What you need to do</u>
◽ The <span style="color: #3366ff;">Train CSV</span> and <span style="color: #3366ff;">Eval CSV</span> should already be populated. If not, just go back to Step 1 and click "Create Dataset" again.<br>
◽ The default settings below are the suggested settings for most purposes, however you may choose to alter them depending on your specific use case.<br>
@@ -1384,10 +1426,6 @@ if __name__ == "__main__":
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- What you are training (A human voice, A cartoon voice, A new language entirely etc)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- How much audio you have (you may want less or more eval or epochs)<br>
◽ The key indicator of sufficient model training is whether it sounds right to you. Coqui suggests beginning with the base settings for training. If the resulting audio doesn't meet your expectations, additional training sessions may be necessary.<br>
◽ **Number of epochs:** Defines how many times the entire dataset is passed through the neural network; more epochs can improve learning but increase the risk of memorizing the training data.<br>
◽ **Batch size:** Sets how many training examples are used in one iteration. Larger sizes speed up training but require more computational memory.<br>
◽ **Grad(ient) accumulation steps:** Allows larger batches by spreading the computation across multiple steps, enabling training with limited hardware resources.<br>
◽ **Max permitted audio size in seconds:** Limits the length of audio that the model processes. Any audio exceeding this duration will be truncated to fit the model's input constraints.<br>
### 🟨 <u>What this step is doing</u><br>
◽ Very simply put, it's taking all our wav files generated in Step 1, along with our recorded speech in out excel documents and its training the model on that voice e.g. listen to this audio file and this is what is being said in it, so learn to reproduce it.<br>
### 🟩 <u>How long will this take?</u><br>
@@ -1398,9 +1436,27 @@ if __name__ == "__main__":
with gr.Row():
train_csv = gr.Textbox(
label="Train CSV:",
scale=2,
)
eval_csv = gr.Textbox(
label="Eval CSV:",
scale=2,
)
learning_rates = gr.Dropdown(
value=5e-6,
label="Learning Rate",
choices=[
("1e-6", 1e-6),
("5e-6", 5e-6),
("1e-5", 1e-5),
("5e-5", 5e-5),
("1e-4", 1e-4),
("5e-4", 5e-4),
("1e-3", 1e-3),
],
type="value",
allow_custom_value=True,
scale=0,
)
with gr.Row():
num_epochs = gr.Slider(
@@ -1419,8 +1475,8 @@ if __name__ == "__main__":
)
grad_acumm = gr.Slider(
label="Grad accumulation steps:",
minimum=2,
maximum=128,
minimum=1,
maximum=32,
step=1,
value=args.grad_acumm,
)
@@ -1456,14 +1512,15 @@ if __name__ == "__main__":
demo.load(read_logs, None, logs_tts_train, every=1)
train_btn = gr.Button(value="Step 2 - Run the training")
def train_model(language, train_csv, eval_csv, num_epochs, batch_size, grad_acumm, output_path, max_audio_length):
def train_model(language, train_csv, eval_csv, learning_rates, num_epochs, batch_size, grad_acumm, output_path, max_audio_length):
clear_gpu_cache()
if not train_csv or not eval_csv:
return "You need to run the data processing step or manually set `Train CSV` and `Eval CSV` fields !", "", "", "", ""
try:
# convert seconds to waveform frames
max_audio_length = int(max_audio_length * 22050)
config_path, original_xtts_checkpoint, vocab_file, exp_path, speaker_wav = train_gpt(language, num_epochs, batch_size, grad_acumm, train_csv, eval_csv, output_path=str(output_path), max_audio_length=max_audio_length)
learning_rate = float(learning_rates) # Convert the learning rate value to a float
config_path, original_xtts_checkpoint, vocab_file, exp_path, speaker_wav = train_gpt(language, num_epochs, batch_size, grad_acumm, train_csv, eval_csv, learning_rate, output_path=str(output_path), max_audio_length=max_audio_length)
except:
traceback.print_exc()
error = traceback.format_exc()
@@ -1477,6 +1534,84 @@ if __name__ == "__main__":
print("[FINETUNE] Model training done. Move to Step 3")
clear_gpu_cache()
return "Model training done. Move to Step 3", config_path, vocab_file, ft_xtts_checkpoint, speaker_wav
with gr.Tab("Info - Grad Accumulation"):
gr.Markdown(
f"""
### 🟩 <u>Grad Accumulation</u><br>
◽ Gradient accumulation is a technique that allows you to simulate a larger batch size without actually increasing the memory consumption. Here's how it works:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ Instead of updating the model's parameters after every batch, gradient accumulation enables you to process multiple batches and accumulate their gradients.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ By setting steps greater than 1, you can process multiple batches before a single optimization step e.g if steps is set to 4, the gradients will be accumulated over 4 batches before updating the model's parameters.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ This means that you can effectively use a larger batch size while keeping the actual batch size per iteration smaller, thereby reducing the memory footprint.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ Increasing the steps allows you to find a balance between memory consumption and computational efficiency. You can process more examples per optimization step without exceeding the available memory.<br><br>
◽ However, it's important to note that increasing the gradient accumulation steps does have an impact on the training process:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ Since the model's parameters are updated less frequently (every grad_accum_steps batches), the training dynamics may be slightly different compared to updating the model after every batch.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ You may need to adjust the learning rate and other hyperparameters accordingly to compensate for the less frequent updates. Typically, you can increase the learning rate slightly when using gradient accumulation.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ The training progress will be slower in terms of the number of optimization steps per epoch, as the model updates occur less frequently.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ However, the overall training time may still be reduced compared to using a smaller batch size without gradient accumulation, as it allows for better utilization of GPU resources.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;◽ To start, you can try setting steps to a value like 4 and see if it resolves the OOM error. If the error persists, you can experiment with higher values until you find a balance that works for your specific setup.
"""
)
with gr.Tab("Info - Batch Size"):
gr.Markdown(
f"""
### 🟩 <u>Batch Size</u><br>
◽ Batch size refers to the number of training examples processed in a single iteration (forward and backward pass) before updating the model's parameters.<br>
◽ A larger batch size allows for more efficient computation and utilization of hardware resources, especially when using GPUs.<br>
◽ However, increasing the batch size also increases the memory consumption during training, as more examples need to be stored in memory.<br>
◽ If the batch size is too large, it can lead to out-of-memory (OOM) errors, especially when training on GPUs with limited memory.<br>
◽ On the other hand, using a smaller batch size can result in slower training and may require more iterations to converge.<br>
◽ The optimal batch size depends on various factors, such as the model architecture, available hardware resources, and the specific problem being solved.<br>
◽ It's common to experiment with different batch sizes to find a balance between training speed and memory efficiency.<br>
◽ If you encounter OOM errors, try reducing the batch size until the training can proceed without memory issues.<br>
◽ Keep in mind that the batch size also affects the model's generalization and convergence behavior, so it's important to monitor the model's performance while adjusting the batch size.
"""
)
with gr.Tab("Info - Learning Rate"):
gr.Markdown(
f"""
### 🟩 <u>Learning Rate</u><br>
◽ 1e-6: Very small learning rate, slow but stable learning.<br>
◽ 5e-6: Small learning rate, slow but stable learning.<br>
◽ 1e-5: Moderate learning rate, balanced between stability and convergence speed.<br>
◽ 5e-5: Higher learning rate, faster convergence but potential instability.<br>
◽ 1e-4: High learning rate, faster convergence but increased risk of instability.<br>
◽ 5e-4: Very high learning rate, fast convergence but higher risk of instability.<br>
◽ 1e-3: Extremely high learning rate, very fast convergence but high risk of instability.<br><br>
The optimal learning rate depends on the model architecture, dataset, and other hyperparameters.
"""
)
with gr.Tab("Info - Epochs"):
gr.Markdown(
f"""
### 🟩 <u>Epochs</u><br>
◽ An epoch represents a single pass through the entire training dataset during the training process.<br>
◽ In each epoch, the model sees and learns from all the training examples once.<br>
◽ The number of epochs determines how many times the model will iterate over the complete training dataset.<br>
◽ Increasing the number of epochs allows the model to learn more from the data and potentially improve its performance.<br>
◽ However, training for too many epochs can lead to overfitting, where the model becomes too specialized to the training data and fails to generalize well to unseen data.<br>
◽ The optimal number of epochs depends on factors such as the complexity of the problem, the size of the dataset, and the model's capacity.<br>
◽ It's common to use techniques like early stopping or validation monitoring to determine the appropriate number of epochs.<br>
◽ Early stopping involves monitoring the model's performance on a validation set and stopping the training when the performance starts to degrade, indicating potential overfitting.<br>
◽ Validation monitoring involves evaluating the model's performance on a separate validation set after each epoch and selecting the model checkpoint that performs best on the validation set.<br>
◽ It's recommended to start with a reasonable number of epochs and monitor the model's performance to determine if more epochs are needed or if early stopping should be applied
"""
)
with gr.Tab("Info - Max Audio"):
gr.Markdown(
f"""
### 🟩 <u>Max Permitted Audio Size (in seconds)</u><br>
◽ The max permitted audio size determines the maximum duration of audio files that can be used as input to the model during training and inference.<br>
◽ It is specified in seconds and represents the longest audio clip that the model can process.<br>
◽ Limiting the audio size helps to control the memory usage and computational requirements of the model.<br>
◽ If the audio files in your dataset vary in length, it's important to consider the max permitted audio size to ensure that all files can be processed effectively.<br>
◽ Audio files longer than the max permitted size will typically be truncated or split into smaller segments before being fed into the model.<br>
◽ The choice of max permitted audio size depends on the specific requirements of your application and the available hardware resources.<br>
◽ Increasing the max permitted audio size allows the model to handle longer audio clips but also increases the memory consumption and computational burden.<br>
◽ If you encounter memory issues or slow processing times, you may need to reduce the max permitted audio size to find a suitable balance.<br>
◽ It's important to consider the nature of your audio data and choose a max permitted audio size that captures the relevant information while being computationally feasible.
"""
)
#######################
#### GRADIO STEP 3 ####
@@ -1572,7 +1707,7 @@ if __name__ == "__main__":
refresh_button = create_refresh_button(
[xtts_checkpoint, xtts_config, xtts_vocab, speaker_reference_audio],
[
lambda: {"choices": find_models(main_directory, "pth"), "value": ""},
lambda: {"choices": find_best_models(main_directory), "value": ""},
lambda: {"choices": find_jsons(main_directory, "config.json"), "value": ""},
lambda: {"choices": find_jsons(main_directory, "vocab.json"), "value": ""},
lambda: {"choices": get_available_voices(), "value": ""},
@@ -1605,7 +1740,8 @@ if __name__ == "__main__":
◽ **Note:** Sample wav files will be copied into the model folder. You will need to MANUALLY copy/move the WAV file(s) you want to use to the AllTalk voices folder, to make them available within the interface.<br>
◽ **Note:** Text-generation-webui users, <span style="color: #3366ff;">OPTION A - Compact and move model to '/trainedmodel/'</span>. will make the model available for use within Text-gen-webui.<br>
### 🟩 <u>Using your Finetuned model as you main model</u>
◽ If you wish to use the model you have just fintuned as your main model, you will need to MANUALLY copy it over the base model in <span style="color: #3366ff;">/models/trainedmodel/</span> after you have used Option A or B.<br>
◽ **Currently** only Text-gen-webui and SillyTavern have loaders built for loading models in the <span style="color: #3366ff;">'/finetuned/'</span> folder. So if you wish to use your finetuned model as elsewhere in AllTalk please copy it over your base model e.g. copy your model over the top of <span style="color: #3366ff;">/models/xttsv2_2.0.2/</span><br>
◽ If you wish to use the model you have just fintuned as your main model, you will need to MANUALLY copy it over the base model e.g copy it over <span style="color: #3366ff;">/models/xttsv2_2.0.2/</span> after you have used Option A or B.<br>
◽ Should you ever wish to revert your model back to the base model, you can delete the files in <span style="color: #3366ff;">/models/xttsv2_2.0.2/</span> and new copies will be re-downloaded when AllTalk starts up.<br>
### 🟨 <u>Clearing up disk space</u>
◽ If you are not going to train anything again, you can delete the whisper model from inside of your huggingface cache (3GB approx) <br>
@@ -1617,6 +1753,21 @@ if __name__ == "__main__":
final_progress_data = gr.Label(
label="Progress:"
)
with gr.Row():
xtts_checkpoint_copy = gr.Dropdown(
[str(file) for file in xtts_checkpoint_files],
label="XTTS checkpoint path (Select the model you want to copy over):",
value="",
allow_custom_value=True,
scale=3,
)
# Create refresh button
refresh_button = create_refresh_button(
[xtts_checkpoint_copy,],
[
lambda: {"choices": find_best_models(main_directory), "value": ""},
],
elem_class="refresh-button-class")
with gr.Row():
compact_btn = gr.Button(value="OPTION A - Compact and move model to '/trainedmodel/'")
gr.Markdown(
@@ -1631,6 +1782,9 @@ if __name__ == "__main__":
This will compact the model and move it, along with the reference wav's to <span style="color: #3366ff;">/models/lastfinetuned/</span> and will <span style="color: red;">OVERWRITE</span> any model in that location. This will just leave you a finetuned model that you can do with as you please. It will <span style="color: red;">NOT</span> be available in Text-gen-webui unless you copy it over one of the other model loader locations.
"""
)
with gr.Row():
compact_custom_btn = gr.Button(value="OPTION C - Compact and move model to a folder name of your choosing")
folder_path = gr.Textbox(label="Enter a new folder name (will be sub the models folder)", lines=1, value="mycustomfolder")
with gr.Row():
delete_training_btn = gr.Button(value="Delete generated training data")
gr.Markdown(
@@ -1653,6 +1807,7 @@ if __name__ == "__main__":
whisper_model,
out_path,
eval_split_number,
speaker_name_input,
],
outputs=[
progress_data,
@@ -1668,6 +1823,7 @@ if __name__ == "__main__":
lang,
train_csv,
eval_csv,
learning_rates,
num_epochs,
batch_size,
grad_acumm,
@@ -1696,13 +1852,19 @@ if __name__ == "__main__":
],
outputs=[progress_gen, tts_output_audio, reference_audio],
)
compact_btn.click(
fn=compact_model,
inputs=[xtts_checkpoint_copy],
outputs=[final_progress_data],
)
compact_lastfinetuned_btn.click(
fn=compact_lastfinetuned_model,
inputs=[xtts_checkpoint_copy],
outputs=[final_progress_data],
)
compact_custom_btn.click(
fn=compact_custom_model,
inputs=[xtts_checkpoint_copy, folder_path],
outputs=[final_progress_data],
)
delete_training_btn.click(
+6 -4
View File
@@ -7,14 +7,16 @@ RUN apt-get update && apt-get upgrade -y \
libclblast-dev libopenblas-dev \
&& mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd \
&& ln -s /usr/bin/python3 /usr/bin/python
RUN mkdir /app/pip_cache
ENV PIP_CACHE_DIR=/app/pip_cache
WORKDIR /app
COPY . .
ENV CUDA_DOCKER_ARCH=all
RUN pip install --no-cache-dir --no-deps -r system/requirements/requirements_standalone.txt --cache-dir=/app/pip_cache && \
pip install --no-cache-dir deepspeed --cache-dir=/app/pip_cache
RUN pip install --no-cache-dir -r requirements_nvidia.txt && \
pip install --no-cache-dir -r requirements_finetune.txt && \
pip install --no-cache-dir -r requirements_other.txt && \
pip install --no-cache-dir deepspeed
EXPOSE 7851
RUN chmod +x launch.sh
ENTRYPOINT ["sh", "-c", "./launch.sh"]
+10 -6
View File
@@ -174,7 +174,7 @@ def get_available_voices():
############################################
def delete_old_files(folder_path, days_to_keep):
current_time = datetime.now()
print(f"[{params['branding']}Startup] \033[92mWAV file deletion :\033[93m {formatted_date}\033[0m",delete_output_wavs_setting,)
print(f"[{params['branding']}Startup] \033[92mWAV file deletion :\033[93m", delete_output_wavs_setting,"\033[0m")
for file_name in os.listdir(folder_path):
file_path = os.path.join(folder_path, file_name)
if os.path.isfile(file_path):
@@ -230,7 +230,7 @@ if finetuned_model:
(trained_model_directory / file).exists() for file in required_files
)
if finetuned_model:
print(f"[{params['branding']}Startup] Finetuned model \033[93mDetected\033[0m")
print(f"[{params['branding']}Startup] \033[92mFinetuned model :\033[93m Detected\033[0m")
####################################################
#### SET GRADIO BUTTONS BASED ON confignew.json ####
@@ -698,9 +698,11 @@ def output_modifier(string, state):
print(f"[{params['branding']}TTSGen] {voice_description}")
# Replace multiple exclamation marks, question marks, or other punctuation with a single instance
cleaned_part = re.sub(r"([!?.])\1+", r"\1", part)
cleaned_part = re.sub(r"([!?.\u3002\uFF1F\uFF01\uFF0C])\1+", r"\1", part)
# Replace "Chinese ellipsis" with a single dot
cleaned_part = re.sub(r"\u2026{1,2}", ". ", cleaned_part)
# Further clean to remove any other unwanted characters
cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0100-\u017F\u0400-\u04FFÀ-ÿ\u0150\u0151\u0170\u0171\u4E00-\u9FFF\u3400-\u4DBF\u20000-\u2A6DF\u3000-\u303F\$]', '', cleaned_part)
cleaned_part = re.sub(r'[^a-zA-Z0-9\s.,;:!?\-\'"$\u0400-\u04FF\u00C0-\u00FF\u0150\u0151\u0170\u0171\u0900-\u097F\u2018\u2019\u201C\u201D\u3001\u3002\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF\uAC00-\uD7A3\u1100-\u11FF\u3130-\u318F\uFF01\uFF0c\uFF1A\uFF1B\uFF1F]', '', cleaned_part)
# Remove all newline characters (single or multiple)
cleaned_part = re.sub(r"\n+", " ", cleaned_part)
@@ -725,9 +727,11 @@ def output_modifier(string, state):
# Decode HTML entities first
cleaned_part = html.unescape(cleaned_string)
# Replace multiple instances of certain punctuation marks with a single instance
cleaned_part = re.sub(r"([!?.])\1+", r"\1", cleaned_part)
cleaned_part = re.sub(r"([!?.\u3002\uFF1F\uFF01\uFF0C])\1+", r"\1", cleaned_part)
# Replace "Chinese ellipsis" with a single dot
cleaned_part = re.sub(r"\u2026{1,2}", ". ", cleaned_part)
# Further clean to remove any other unwanted characters
cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0100-\u017F\u0400-\u04FFÀ-ÿ\u0150\u0151\u0170\u0171\u4E00-\u9FFF\u3400-\u4DBF\u20000-\u2A6DF\u3000-\u303F\$]', '', cleaned_part)
cleaned_part = re.sub(r'[^a-zA-Z0-9\s.,;:!?\-\'"$\u0400-\u04FF\u00C0-\u00FF\u0150\u0151\u0170\u0171\u0900-\u097F\u2018\u2019\u201C\u201D\u3001\u3002\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF\uAC00-\uD7A3\u1100-\u11FF\u3130-\u318F\uFF01\uFF0c\uFF1A\uFF1B\uFF1F]', '', cleaned_part)
# Remove all newline characters (single or multiple)
cleaned_part = re.sub(r"\n+", " ", cleaned_part)
# Process the part and give it a non-character name if being used vai API or standalone.
+2
View File
@@ -304,6 +304,7 @@
<option value="nl">Dutch</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="hi">Hindi</option>
<option value="hu">Hungarian</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
@@ -2500,6 +2501,7 @@
<code>en</code> English<br>
<code>fr</code> French<br>
<code>de</code> German<br>
<code>hi</code> Hindi<br>
<code>hu</code> Hungarian<br>
<code>it</code> Italian<br>
<code>ja</code> Japanese<br>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 440 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 11 KiB

+1
View File
@@ -124,6 +124,7 @@
<option value="English" {% if data.language=='English' %}selected{% endif %}>English</option>
<option value="French" {% if data.language=='French' %}selected{% endif %}>French</option>
<option value="German" {% if data.language=='German' %}selected{% endif %}>German</option>
<option value="Hindi" {% if data.language=='Hindi' %}selected{% endif %}>Hindi</option>
<option value="Hungarian" {% if data.language=='Hungarian' %}selected{% endif %}>Hungarian</option>
<option value="Italian" {% if data.language=='Italian' %}selected{% endif %}>Italian</option>
<option value="Japanese" {% if data.language=='Japanese' %}selected{% endif %}>Japanese</option>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 KiB

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 547 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 52 KiB

+1
View File
@@ -6,6 +6,7 @@
"English": "en",
"French": "fr",
"German": "de",
"Hindi": "hi",
"Hungarian": "hu",
"Italian": "it",
"Japanese": "ja",
+173
View File
@@ -0,0 +1,173 @@
absl-py==2.1.0
aiofiles==23.2.1
aiohttp==3.9.3
aiosignal==1.3.1
altair==5.2.0
annotated-types==0.6.0
anyascii==0.3.2
anyio==4.3.0
attrs==23.2.0
audioread==3.0.1
av==11.0.0
Babel==2.14.0
bangla==0.0.2
blinker==1.7.0
blis==0.7.11
bnnumerizer==0.0.2
bnunicodenormalizer==0.1.6
catalogue==2.0.10
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
cloudpathlib==0.16.0
colorama==0.4.6
coloredlogs==15.0.1
confection==0.1.4
contourpy==1.2.0
coqpit==0.0.17
ctranslate2==4.1.0
cutlet==0.4.0
cycler==0.12.1
cymem==2.0.8
Cython==3.0.9
dateparser==1.1.8
decorator==5.1.1
docopt==0.6.2
einops==0.7.0
encodec==0.1.1
exceptiongroup
fastapi==0.110.0
faster-whisper==1.0.1
ffmpy==0.3.2
filelock==3.13.3
Flask==3.0.2
flatbuffers==24.3.25
fonttools==4.50.0
frozenlist==1.4.1
fsspec==2024.3.1
fugashi==1.3.1
fuzzywuzzy>=0.18.0
g2pkk==0.1.2
gradio==3.50.2
gradio_client==0.6.1
grpcio==1.62.1
gruut==2.2.3
gruut-ipa==0.13.0
gruut-lang-de==2.0.0
gruut-lang-en==2.0.0
gruut-lang-es==2.0.0
gruut-lang-fr==2.0.2
h11==0.14.0
hangul-romanize==0.1.0
httpcore==1.0.4
httpx==0.27.0
huggingface-hub==0.22.1
humanfriendly==10.0
idna==3.6
importlib_metadata==7.1.0
importlib_resources==6.4.0
inflect==7.0.0
itsdangerous==2.1.2
jaconv==0.3.4
jamo==0.4.1
jieba==0.42.1
Jinja2==3.1.3
joblib==1.3.2
jsonlines==1.2.0
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
kiwisolver==1.4.5
langcodes==3.3.0
lazy_loader==0.3
librosa==0.10.1
llvmlite==0.42.0
Markdown==3.6
MarkupSafe==2.1.5
matplotlib==3.8.3
mojimoji==0.0.13
mpmath==1.3.0
msgpack==1.0.8
multidict==6.0.5
murmurhash==1.0.10
networkx==2.8.8
nltk==3.8.1
num2words==0.5.13
numba==0.59.1
numpy==1.26.4
nvidia-cublas-cu11>=11.11.3.6
nvidia-cudnn-cu11>=9.0.0.312
onnxruntime==1.17.1
orjson==3.9.15
packaging==24.0
pandas==1.5.3
pillow==10.2.0
platformdirs==4.2.0
pooch==1.8.1
preshed==3.0.9
protobuf==5.26.0
psutil==5.9.8
pycparser==2.21
pydantic==2.6.4
pydantic_core==2.16.3
pydub==0.25.1
pynndescent==0.5.11
pyparsing==3.1.2
pypinyin==0.51.0
pyreadline3==3.4.1
pysbd==0.3.4
python-crfsuite==0.9.10
python-dateutil==2.9.0.post0
python-Levenshtein>=0.25.0
python-multipart==0.0.9
pytz==2024.1
PyYAML==6.0.1
referencing==0.34.0
regex==2023.12.25
requests==2.31.0
rpds-py==0.18.0
safetensors==0.4.2
scikit-learn==1.4.1.post1
scipy==1.12.0
semantic-version==2.10.0
six==1.16.0
smart-open==6.4.0
sniffio==1.3.1
sounddevice==0.4.6
soundfile==0.12.1
soxr==0.3.7
spacy==3.7.4
spacy-legacy==3.0.12
spacy-loggers==1.0.5
srsly==2.4.8
starlette==0.36.3
SudachiDict-core==20240109
SudachiPy==0.6.8
sympy==1.12
tensorboard==2.16.2
tensorboard-data-server==0.7.2
thinc==8.2.3
threadpoolctl==3.4.0
tokenizers==0.15.2
toolz==0.12.1
torch>=2.2.0
torchaudio>=2.2.0
tqdm==4.66.2
trainer==0.0.36
transformers==4.39.1
TTS==0.22.0
typer==0.9.4
typing_extensions==4.10.0
tzdata==2024.1
tzlocal==5.2
umap-learn==0.5.5
Unidecode==1.3.8
unidic-lite==1.0.8
urllib3==2.2.1
uvicorn==0.29.0
wasabi==1.1.2
weasel==0.3.4
websockets==11.0.3
Werkzeug==3.0.1
yarl==1.9.4
zipp==3.18.1
+3 -2
View File
@@ -3,8 +3,8 @@ soundfile>=0.12.1
uvicorn>=0.24.0.post1
transformers>=4.37.1
TTS>=0.22.0
torch>=2.1.0+cu118
torchaudio>=2.1.0+cu118
torch>=2.1.0
torchaudio>=2.1.0
fastapi>=0.104.1
Jinja2>=3.1.2
requests>=2.31.0
@@ -22,3 +22,4 @@ nvidia-cublas-cu11>=11.11.3.6
nvidia-cudnn-cu11>=9.0.0.312
fuzzywuzzy>=0.18.0
python-Levenshtein>=0.25.0
spacy>=3.7.2
+1 -1
View File
@@ -281,7 +281,7 @@ class AllTalkTtsProvider {
if (narratorVoiceSelect) narratorVoiceSelect.disabled = !this.settings.narrator_enabled;
}
const modelSelect = document.getElementById('switch_model');
if (this.settings.finetuned_model === 'true') {
if (this.settings.finetuned_model === true) {
const ftOption = document.createElement('option');
ftOption.value = 'XTTSv2 FT';
ftOption.textContent = 'XTTSv2 FT';
+1 -1
View File
@@ -1,2 +1,2 @@
var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,(o=a.key,i=void 0,i=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!==n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===n(i)?i:String(i)),a)}var o,i}e.d(t,{Z:()=>u});var u=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.sampleRate;o(this,e),this._context=this._createContext(n),n||(n=this._context.sampleRate),this._sampleRate=n}var t,n,a;return t=e,n=[{key:"_createContext",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:44100;return window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,new AudioContext({sampleRate:e})}},{key:"context",get:function(){return this._context}},{key:"fetchAudio",value:async function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return await Promise.all(n.map((async function(t){var n;return n=t instanceof File||t instanceof Blob?await t.arrayBuffer():await fetch(t).then((function(e){return e.headers.has("Content-Type")&&!e.headers.get("Content-Type").includes("audio/")&&console.warn("Crunker: Attempted to fetch an audio file, but its MIME type is `".concat(e.headers.get("Content-Type").split(";")[0],"`. We'll try and continue anyway. (file: \"").concat(t,'")')),e.arrayBuffer()})),await e._context.decodeAudioData(n)})))}},{key:"mergeAudio",value:function(e){var t=this._context.createBuffer(this._maxNumberOfChannels(e),this._sampleRate*this._maxDuration(e),this._sampleRate);return e.forEach((function(e){for(var n=0;n<e.numberOfChannels;n++){for(var r=t.getChannelData(n),a=e.getChannelData(n),o=e.getChannelData(n).length-1;o>=0;o--)r[o]+=a[o];t.getChannelData(n).set(r)}})),t}},{key:"concatAudio",value:function(e){var t=this._context.createBuffer(this._maxNumberOfChannels(e),this._totalLength(e),this._sampleRate),n=0;return e.forEach((function(e){for(var r=0;r<e.numberOfChannels;r++)t.getChannelData(r).set(e.getChannelData(r),n);n+=e.length})),t}},{key:"padAudio",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0===n)return e;if(t<0)throw new Error('Crunker: Parameter "padStart" in padAudio must be positive');if(n<0)throw new Error('Crunker: Parameter "seconds" in padAudio must be positive');for(var r=this._context.createBuffer(e.numberOfChannels,Math.ceil(e.length+n*e.sampleRate),e.sampleRate),a=0;a<e.numberOfChannels;a++){var o=e.getChannelData(a);r.getChannelData(a).set(o.subarray(0,Math.ceil(t*e.sampleRate)+1),0),r.getChannelData(a).set(o.subarray(Math.ceil(t*e.sampleRate)+2,r.length+1),Math.ceil((t+n)*e.sampleRate))}return r}},{key:"sliceAudio",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(t>=n)throw new Error('Crunker: "start" time should be less than "end" time in sliceAudio method');for(var o=Math.round((n-t)*this._sampleRate),i=Math.round(t*this._sampleRate),u=this._context.createBuffer(e.numberOfChannels,o,this._sampleRate),l=0;l<e.numberOfChannels;l++)for(var s=e.getChannelData(l),c=u.getChannelData(l),f=0;f<o;f++)c[f]=s[i+f],f<r*this._sampleRate&&(c[f]*=f/(r*this._sampleRate)),f>o-a*this._sampleRate&&(c[f]*=(o-f)/(a*this._sampleRate));return u}},{key:"play",value:function(e){var t=this._context.createBufferSource();return t.buffer=e,t.connect(this._context.destination),t.start(),Line truncated
var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,(o=a.key,i=void 0,i=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!==n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===n(i)?i:String(i)),a)}var o,i}e.d(t,{Z:()=>u});var u=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.sampleRate;o(this,e),this._context=this._createContext(n),n||(n=this._context.sampleRate),this._sampleRate=n}var t,n,a;return t=e,n=[{key:"_createContext",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:44100;return window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,new AudioContext({sampleRate:e})}},{key:"context",get:function(){return this._context}},{key:"fetchAudio",value:async function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return await Promise.all(n.map((async function(t){var n;return n=t instanceof File||t instanceof Blob?await t.arrayBuffer():await fetch(t).then((function(e){return e.headers.has("Content-Type")&&!e.headers.get("Content-Type").includes("audio/")&&console.warn("Crunker: Attempted to fetch an audio file, but its MIME type is `".concat(e.headers.get("Content-Type").split(";")[0],"`. We'll try and continue anyway. (file: \"").concat(t,'")')),e.arrayBuffer()})),await e._context.decodeAudioData(n)})))}},{key:"mergeAudio",value:function(e){var t=this._context.createBuffer(this._maxNumberOfChannels(e),this._sampleRate*this._maxDuration(e),this._sampleRate);return e.forEach((function(e){for(var n=0;n<e.numberOfChannels;n++){for(var r=t.getChannelData(n),a=e.getChannelData(n),o=e.getChannelData(n).length-1;o>=0;o--)r[o]+=a[o];t.getChannelData(n).set(r)}})),t}},{key:"concatAudio",value:function(e){var t=this._context.createBuffer(this._maxNumberOfChannels(e),this._totalLength(e),this._sampleRate),n=0;return e.forEach((function(e){for(var r=0;r<e.numberOfChannels;r++)t.getChannelData(r).set(e.getChannelData(r),n);n+=e.length})),t}},{key:"padAudio",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(0===n)return e;if(t<0)throw new Error('Crunker: Parameter "padStart" in padAudio must be positive');if(n<0)throw new Error('Crunker: Parameter "seconds" in padAudio must be positive');for(var r=this._context.createBuffer(e.numberOfChannels,Math.ceil(e.length+n*e.sampleRate),e.sampleRate),a=0;a<e.numberOfChannels;a++){var o=e.getChannelData(a);r.getChannelData(a).set(o.subarray(0,Math.ceil(t*e.sampleRate)+1),0),r.getChannelData(a).set(o.subarray(Math.ceil(t*e.sampleRate)+2,r.length+1),Math.ceil((t+n)*e.sampleRate))}return r}},{key:"sliceAudio",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(t>=n)throw new Error('Crunker: "start" time should be less than "end" time in sliceAudio method');for(var o=Math.round((n-t)*this._sampleRate),i=Math.round(t*this._sampleRate),u=this._context.createBuffer(e.numberOfChannels,o,this._sampleRate),l=0;l<e.numberOfChannels;l++)for(var s=e.getChannelData(l),c=u.getChannelData(l),f=0;f<o;f++)c[f]=s[i+f],f<r*this._sampleRate&&(c[f]*=f/(r*this._sampleRate)),f>o-a*this._sampleRate&&(c[f]*=(o-f)/(a*this._sampleRate));return u}},{key:"play",value:function(e){var t=this._context.createBufferSource();return t.buffer=e,t.connect(this._context.destination),t.start(),Line truncated
//# sourceMappingURL=crunker.esm.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"crunker.esm.js","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,8jDCoBlF,IAGqBI,EAAO,WAU1B,aAAqE,6DAAJ,CAAC,EAApDC,EAAU,EAAVA,WAAU,UACtBC,KAAKC,SAAWD,KAAKE,eAAeH,GAEpCA,IAAAA,EAAeC,KAAKC,SAASF,YAE7BC,KAAKG,YAAcJ,CACrB,C,UA6YC,O,EA3YD,E,EAAA,6BAKA,WAAkE,IAA3CA,EAAqB,UAAH,6CAAG,MAE1C,OADAK,OAAOC,aAAeD,OAAOC,cAAiBD,OAAeE,oBAAuBF,OAAeG,gBAC5F,IAAIF,aAAa,CAAEN,WAAAA,GAC5B,GAEA,mBAIA,WACE,OAAOC,KAAKC,QACd,GAEA,wBAGAO,iBAA4E,kCAAxDC,EAAS,yBAATA,EAAS,gBAC3B,aAAaC,QAAQC,IACnBF,EAAUG,KAAIJ,eAAOK,GACnB,IAAIC,EAkBJ,OAfEA,EADED,aAAoBE,MAAQ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B,GAEiBD,EAEnC9E,EAAc,IAAIgF,YALD,EAK8BD,GAC/CE,EAAO,IAAIC,SAASlF,GAgB1B,OAdAjB,KAAKoG,aAAaF,EAAM,EAAG,QAC3BA,EAAKG,UAAU,EAAGL,GAAgB,GAClChG,KAAKoG,aAAaF,EAAM,EAAG,QAC3BlG,KAAKoG,aAAaF,EAAM,GAAI,QAC5BA,EAAKG,UAAU,GAAI,IAAI,GACvBH,EAAKI,UAAU,GAAI,GAAG,GACtBJ,EAAKI,UAAU,GAAIV,GAAe,GAClCM,EAAKG,UAAU,GAAItG,GAAY,GAC/BmG,EAAKG,UAAU,GAAItG,EAAa8F,GAAY,GAC5CK,EAAKI,UAAU,GAAIT,GAAY,GAC/BK,EAAKI,UAAU,GAtBE,IAsBY,GAC7BtG,KAAKoG,aAAaF,EAAM,GAAI,QAC5BA,EAAKG,UAAU,GAAIN,GAAe,GAE3B/F,KAAKuG,iBAAiBL,EAAMpF,EAAQ0F,GAC7C,GAEA,8BAKA,SAAyBrC,EAAoBrD,EAAsB6B,GACjE,IAAK,IAAIJ,EAAI,EAAGA,EAAIzB,EAAO0B,OAAQD,IAAKI,GAAU,EAAG,CACnD,IAAM8D,EAAMzD,KAAKwC,KAAK,EAAGxC,KAAK0D,IAAI,EAAG5F,EAAOyB,KAC5C4B,EAASwC,SAAShE,EAAQ8D,EAAM,EAAU,MAANA,EAAqB,MAANA,GAAc,EACnE,CAEA,OAAOtC,CACT,GAEA,0BAKA,SAAqBA,EAAoBxB,EAAgBiE,GACvD,IAAK,IAAIrE,EAAI,EAAGA,EAALine truncated
+13 -9
View File
@@ -532,6 +532,7 @@
<option value="en" selected>English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="hi">Hindi</option>
<option value="hu">Hungarian</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
@@ -921,18 +922,21 @@
const playType = document.getElementById('playType').value; // Play type (chunk or stream)
playModeValue = document.getElementById('playMode').value;
let cleanedText = textInput.replace(/ \- | \– /g, ' ');
let cleanedText = textInput.replace(/ \\- | \\– /g, ' ');
cleanedText = cleanedText.replace(/%/g, " percent");
cleanedText = cleanedText.replace(/\.\s'/g, ".'");
cleanedText = cleanedText.replace(/(?<!\w)[']+(?!\w)/g, '');
cleanedText = cleanedText.replace(/\\.\\s'/g, ".'");
cleanedText = cleanedText.replace(/(?<!\\w)\['\]+(?!\\w)/g, '');
cleanedText = cleanedText.replace(/"/g, "'");
cleanedText = cleanedText.replace(/[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ\u0400-\u04FF\u0150\u0151\u0170\u0171]\$/g, '');
// Replace dash followed by space with comma and space
cleanedText = cleanedText.replace(/-\s/g, '; ');
// Replace double dash "--" with semicolon "; "
cleanedText = cleanedText.replace(/[^a-zA-Z0-9\s.,;:!?\-'"$À-ÿ\u0400-\u04FF\u0150\u0151\u0170\u0171\u0900-\u097F\u2018\u2019\u201C\u201D\u2026\u3001\u3002\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF\uAC00-\uD7A3\u1100-\u11FF\u3130-\u318F\uFF01\uFF0c\uFF1A\uFF1B\uFF1F]/g, '');
cleanedText = cleanedText.replace(/-\\s/g, '; ');
cleanedText = cleanedText.replace(/--/g, '; ');
let sentences = cleanedText.split(/(?<=[.!?:])\s+/);
// Split by Fullwidth/CJK punctuation regardless of if there are spaces behind them
// Please test if it works properly. In my test they it should be
// (?<=[.!?:])\s+ instead of
// (?<=\[.!?:\])\\s+
// so I don't know whats going on here
// let sentences = cleanedText.split(/(?<=[\[.!?:\]])\s+|(?<=[\u3002\uFF01\uFF1A\uFF1F])/);
let sentences = cleanedText.split(/(?<=[\[.!?:\]]['"\u2018\u2019\u201C\u201D]*)\s+|(?<=[\u3002\uFF01\uFF1A\uFF1F])/);
if (!sentences) {
console.error("No sentences found in the input text.");
File diff suppressed because it is too large. Load diff
+50 -15
View File
@@ -476,6 +476,11 @@ async def deepspeed(request: Request, new_deepspeed_value: bool):
########################
#### TTS GENERATION ####
########################
debug_generate_audio = False
tts_stop_generation = False # Called to stop generation of the current text at whatever stage its at. currently only set for streaming.
tts_generation_lock = False # Tracks locking of the generaetion process.
tts_narrator_generatingtts = False # Tracks if the current tts processes are narrator based, to avoid moving model on each chunk of text generated.
# Not in use tts_queue_behaviour = False # True is to queue the current generation request. False is to cancel the current generation and start a new one.
# TTS VOICE GENERATION METHODS (called from voice_preview and output_modifer)
async def generate_audio(text, voice, language, temperature, repetition_penalty, output_file, streaming=False):
@@ -487,8 +492,10 @@ async def generate_audio(text, voice, language, temperature, repetition_penalty,
async for _ in response:
pass
async def generate_audio_internal(text, voice, language, temperature, repetition_penalty, output_file, streaming):
global model
global model, tts_stop_generation, tts_generation_lock
tts_generation_lock = True
if params["low_vram"] and device == "cpu":
await switch_device()
generate_start_time = time.time() # Record the start time of generating TTS
@@ -539,6 +546,12 @@ async def generate_audio_internal(text, voice, language, temperature, repetition
yield wav_buf.read()
for i, chunk in enumerate(output):
if tts_stop_generation:
print(f"[{params['branding']}TTSGen] Stopping audio generation.")
file_chunks.clear() # Clear the file_chunks list
tts_stop_generation = False
tts_generation_lock = False
break
file_chunks.append(chunk)
if isinstance(chunk, list):
chunk = torch.cat(chunk, dim=0)
@@ -547,6 +560,7 @@ async def generate_audio_internal(text, voice, language, temperature, repetition
chunk = np.clip(chunk, -1, 1)
chunk = (chunk * 32767).astype(np.int16)
yield chunk.tobytes()
print(f"[{params['branding']}Debug] Stream audio generation: Yielded audio chunk {i}.") if debug_generate_audio else None
else:
# Non-streaming-specific operation
torchaudio.save(output_file, torch.tensor(output["wav"]).unsqueeze(0), 24000)
@@ -565,9 +579,9 @@ async def generate_audio_internal(text, voice, language, temperature, repetition
file_path=output_file,
speaker_wav=[f"{this_dir}/voices/{voice}"],
language=language,
temperature=temperature,
length_penalty=model.config.length_penalty,
repetition_penalty=repetition_penalty,
temperature=float(temperature),
length_penalty=float(model.config.length_penalty),
repetition_penalty=float(repetition_penalty),
top_k=model.config.top_k,
top_p=model.config.top_p,
)
@@ -589,12 +603,11 @@ async def generate_audio_internal(text, voice, language, temperature, repetition
# Print Generation time and settings
generate_end_time = time.time() # Record the end time to generate TTS
generate_elapsed_time = generate_end_time - generate_start_time
print(
f"[{params['branding']}TTSGen] \033[93m{generate_elapsed_time:.2f} seconds. \033[94mLowVRAM: \033[33m{params['low_vram']} \033[94mDeepSpeed: \033[33m{params['deepspeed_activate']}\033[0m"
)
print(f"[{params['branding']}TTSGen] \033[93m{generate_elapsed_time:.2f} seconds. \033[94mLowVRAM: \033[33m{params['low_vram']} \033[94mDeepSpeed: \033[33m{params['deepspeed_activate']}\033[0m")
# Move model back to cpu system ram if needed.
if params["low_vram"] and device == "cuda":
if params["low_vram"] and device == "cuda" and tts_narrator_generatingtts == False:
await switch_device()
tts_generation_lock = False
return
@@ -854,6 +867,13 @@ async def tts_generate_streaming(request: Request, text: str = Form(...), voice:
print(f"An error occurred: {e}")
return JSONResponse(content={"error": "An error occurred"}, status_code=500)
@app.put("/api/stop-generation")
async def stop_generation_endpoint():
global tts_stop_generation, tts_generation_lock
if tts_generation_lock and not tts_stop_generation:
tts_stop_generation = True
return {"message": "Generation stopped"}
##############################
#### Standard Generation ####
##############################
@@ -890,7 +910,7 @@ class JSONInput(BaseModel):
narrator_enabled: bool = Field(..., description="narrator_enabled needs to be true or false.")
narrator_voice_gen: str = Field(..., pattern="^.*\.wav$", description="narrator_voice_gen needs to be the name of a wav file e.g. mysample.wav.")
text_not_inside: str = Field(..., pattern="^(character|narrator)$", description="text_not_inside needs to be 'character' or 'narrator'.")
language: str = Field(..., pattern="^(ar|zh-cn|cs|nl|en|fr|de|hu|it|ja|ko|pl|pt|ru|es|tr)$", description="language needs to be one of the following ar|zh-cn|cs|nl|en|fr|de|hu|it|ja|ko|pl|pt|ru|es|tr.")
language: str = Field(..., pattern="^(ar|zh-cn|cs|nl|en|fr|de|hu|hi|it|ja|ko|pl|pt|ru|es|tr)$", description="language needs to be one of the following ar|zh-cn|cs|nl|en|fr|de|hu|hi|it|ja|ko|pl|pt|ru|es|tr.")
output_file_name: str = Field(..., pattern="^[a-zA-Z0-9_]+$", description="output_file_name needs to be the name without any special characters or file extension e.g. 'filename'")
output_file_timestamp: bool = Field(..., description="output_file_timestamp needs to be true or false.")
autoplay: bool = Field(..., description="autoplay needs to be a true or false value.")
@@ -1029,12 +1049,17 @@ async def tts_generate(
"autoplay_volume": autoplay_volume,
"streaming": streaming,
}
global tts_narrator_generatingtts
JSONresult = TTSGenerator.validate_json_input(json_input_data)
if JSONresult is None:
pass
else:
print(f"[{params['branding']}API] \033[91mError with API request:\033[0m", JSONresult)
return JSONResponse(content={"error": JSONresult}, status_code=400)
if narrator_enabled:
if params["low_vram"] and device == "cpu":
await switch_device()
tts_narrator_generatingtts = True
processed_parts = process_text(text_input)
audio_files_all_paragraphs = []
for part_type, part in processed_parts:
@@ -1054,9 +1079,11 @@ async def tts_generate(
voice_description = "\033[36mCharacter (Text-not-inside)\033[0m" if text_not_inside == "character" else "\033[92mNarrator (Text-not-inside)\033[0m"
print(f"[{params['branding']}TTSGen] {voice_description}")
# Replace multiple exclamation marks, question marks, or other punctuation with a single instance
cleaned_part = re.sub(r'([!?.])\1+', r'\1', part)
cleaned_part = re.sub(r'([!?.\u3002\uFF1F\uFF01\uFF0C])\1+', r'\1', part)
# Replace "Chinese ellipsis" with a single dot
cleaned_part = re.sub(r"\u2026{1,2}", ". ", cleaned_part)
# Further clean to remove any other unwanted characters
cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\u0150\u0151\u0170\u0171]\$', '', cleaned_part)
cleaned_part = re.sub(r'[^a-zA-Z0-9\s.,;:!?\-\'"$\u0400-\u04FF\u00C0-\u00FF\u0150\u0151\u0170\u0171\u0900-\u097F\u2018\u2019\u201C\u201D\u3001\u3002\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF\uAC00-\uD7A3\u1100-\u11FF\u3130-\u318F\uFF01\uFF0c\uFF1A\uFF1B\uFF1F]', '', cleaned_part)
# Remove all newline characters (single or multiple)
cleaned_part = re.sub(r'\n+', ' ', cleaned_part)
output_file = this_dir / "outputs" / f"{output_file_name}_{uuid.uuid4()}_{int(time.time())}.wav"
@@ -1066,6 +1093,10 @@ async def tts_generate(
audio_files_all_paragraphs.append(audio_path)
# Combine audio files across paragraphs
output_file_path, output_file_url, output_cache_url = combine(output_file_timestamp, output_file_name, audio_files_all_paragraphs)
tts_narrator_generatingtts = False
# Move model back to cpu system ram if needed.
if params["low_vram"] and device == "cuda":
await switch_device()
else:
if output_file_timestamp:
timestamp = int(time.time())
@@ -1085,15 +1116,19 @@ async def tts_generate(
output_cache_url = f'http://{params["ip_address"]}:{params["port_number"]}/audiocache/{output_file_name}.wav'
if text_filtering == "html":
cleaned_string = html.unescape(standard_filtering(text_input))
cleaned_string = re.sub(r'([!?.])\1+', r'\1', text_input)
cleaned_string = re.sub(r'([!?.\u3002\uFF1F\uFF01\uFF0C])\1+', r'\1', text_input)
# Replace "Chinese ellipsis" with a single dot
cleaned_string = re.sub(r"\u2026{1,2}", ". ", cleaned_string)
# Further clean to remove any other unwanted characters
cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\u0150\u0151\u0170\u0171]\$', '', cleaned_string)
cleaned_string = re.sub(r'[^a-zA-Z0-9\s.,;:!?\-\'"$\u0400-\u04FF\u00C0-\u00FF\u0150\u0151\u0170\u0171\u0900-\u097F\u2018\u2019\u201C\u201D\u3001\u3002\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF\uAC00-\uD7A3\u1100-\u11FF\u3130-\u318F\uFF01\uFF0c\uFF1A\uFF1B\uFF1F]', '', cleaned_string)
# Remove all newline characters (single or multiple)
cleaned_string = re.sub(r'\n+', ' ', cleaned_string)
elif text_filtering == "standard":
cleaned_string = re.sub(r'([!?.])\1+', r'\1', text_input)
cleaned_string = re.sub(r'([!?.\u3002\uFF1F\uFF01\uFF0C])\1+', r'\1', text_input)
# Replace "Chinese ellipsis" with a single dot
cleaned_string = re.sub(r"\u2026{1,2}", ". ", cleaned_string)
# Further clean to remove any other unwanted characters
cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\u0150\u0151\u0170\u0171]\$', '', cleaned_string)
cleaned_string = re.sub(r'[^a-zA-Z0-9\s.,;:!?\-\'"$\u0400-\u04FF\u00C0-\u00FF\u0150\u0151\u0170\u0171\u0900-\u097F\u2018\u2019\u201C\u201D\u3001\u3002\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF\uAC00-\uD7A3\u1100-\u11FF\u3130-\u318F\uFF01\uFF0c\uFF1A\uFF1B\uFF1F]', '', cleaned_string)
# Remove all newline characters (single or multiple)
cleaned_string = re.sub(r'\n+', ' ', cleaned_string)
else: