From b5b68ad51f37f6c2bc879efac96621e66384e287 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sat, 23 Dec 2023 00:16:38 +0000 Subject: [PATCH 01/39] Update script.py updated timeout --- script.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script.py b/script.py index a641bf9..c185a33 100644 --- a/script.py +++ b/script.py @@ -248,7 +248,7 @@ else: # Cleanly kill off this script, but allow text-generation-webui to keep running, albeit without this alltalk_tts sys.exit(1) -timeout = 60 # Adjust the timeout as needed +timeout = 120 # Adjust the timeout as needed # Introduce a delay before starting the check loop time.sleep(25) # Wait 25 secs before checking if the tts_server.py has started up. @@ -261,7 +261,7 @@ while time.time() - start_time < timeout: except requests.RequestException as e: # Print the exception for debugging purposes print( - f"[{params['branding']}Startup] \033[91mWarning\033[0m TTS Subprocess has NOT started up yet, Will keep trying for 60 seconds maximum. Please wait." + f"[{params['branding']}Startup] \033[91mWarning\033[0m TTS Subprocess has NOT started up yet, Will keep trying for 120 seconds maximum. Please wait." ) time.sleep(1) else: @@ -888,4 +888,4 @@ if running_in_standalone: try: time.sleep(1) # Add a small delay to avoid high CPU usage except KeyboardInterrupt: - break # Allow graceful exit on Ctrl+C \ No newline at end of file + break # Allow graceful exit on Ctrl+C From de4017f385182c7cb79d4b5516f17ae8c00f2988 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:07:22 +0000 Subject: [PATCH 02/39] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9b8755e..38afe78 100644 --- a/README.md +++ b/README.md @@ -174,9 +174,9 @@ Assuming its all working fine and you are happy, you can delete the old alltalk_ **A)** Its trying to load the voice model into your graphics card VRAM (assuming you have a Nvidia Graphics card, otherwise its your system RAM)
**B)** Its trying to start up the mini-webserver and send the "ready" signal back to the main process. -**Note:** If you need to create a support ticket, please create a `diagnostics.log` report file to submit with a support request. Details on doing this are above. +Before giving other possibilities a go, some people with **old machines** are finding their startup times are **very** slow 2-3 minutes. Ive extended the allowed time within the script from 1 minute to 2 minutes. **If you have an older machine** and wish to try extending this further, you can do so by editing `script.py` and changing line 251 `timeout = 120` changing the timeout to a larger value e.g `timeout = 240` (4 minutes). -Before giving other possibilities, some people with **old machines** are finding their startup times are **very** slow 2-3 minutes. Ive extended the allowed time within the script from 1 minute to 2 minutes. **If you have an older machine** and wish to try extending this further, you can do so by editing `script.py` and changing line 251 `timeout = 120` changing the timeout to a larger value e.g `timeout = 240` (4 minutes). +**Note:** If you need to create a support ticket, please create a `diagnostics.log` report file to submit with a support request. Details on doing this are above. Other possibilities for this issue are: From e4eaa760b93f87981e5e42ff66b00633d25d0c55 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:16:46 +0000 Subject: [PATCH 03/39] Update requirements_nvidia.txt --- requirements_nvidia.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_nvidia.txt b/requirements_nvidia.txt index 64bdcfe..d07a735 100644 --- a/requirements_nvidia.txt +++ b/requirements_nvidia.txt @@ -10,3 +10,4 @@ requests>=2.31.0 tqdm>=4.66.1 importlib-metadata>=4.8.1 packaging>=23.2 +pydantic>=2.5.0 From da0445489e77a077ddfcac2da744065dfb2c3985 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:17:07 +0000 Subject: [PATCH 04/39] Update requirements_other.txt --- requirements_other.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_other.txt b/requirements_other.txt index 667d885..fdc8640 100644 --- a/requirements_other.txt +++ b/requirements_other.txt @@ -10,3 +10,4 @@ requests>=2.31.0 tqdm>=4.66.1 importlib-metadata>=4.8.1 packaging>=23.2 +pydantic>=2.5.0 From 2b175b13c4e66662708aae449c50bdff608a4d4d Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sun, 24 Dec 2023 15:56:44 +0000 Subject: [PATCH 05/39] update to find mp3 and flac Forgot it was only looking for wav's! --- finetune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finetune.py b/finetune.py index 3ab2be7..4312c8e 100644 --- a/finetune.py +++ b/finetune.py @@ -59,7 +59,7 @@ def create_temporary_file(folder, suffix=".wav"): return os.path.join(folder, unique_filename) def format_audio_list(target_language, whisper_model, out_path, gradio_progress=progress): - audio_files = [os.path.join(audio_folder, file) for file in os.listdir(audio_folder) if file.endswith('.wav')] + 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=0.15 speaker_name="coqui" From d7376fa8ef5b8568d68d3cbc0e7d65b26a1371e0 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:01:33 +0000 Subject: [PATCH 06/39] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 38afe78..73b0c3c 100644 --- a/README.md +++ b/README.md @@ -267,6 +267,8 @@ As mentioned you must have a small portion of the Nvidia CUDA Toolkit **11.8** i - If it doesnt report that, check you have correctly set the search environment paths, dont have overlapping other versions of cuda paths etc. #### ⚫ Starting Finetuning +**NOTE:** Please make sure you have started AllTalk at least once after updating, so that it downloads the additional files needed for finetuning. + 1) Close all other applications that are using your GPU/VRAM and copy your audio samples into:

`/alltalk_tts/finetune/put-voice-samples-in-here/` 3) In a command prompt/terminal window you need to move into your Text generation webUI folder:

From 993d065368385c2a03c06a1359fdb6a4b0227689 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sun, 24 Dec 2023 18:01:27 +0000 Subject: [PATCH 07/39] Few minor updates Couple of documentation spelling mistakes Set environment variable --- finetune.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/finetune.py b/finetune.py index 4312c8e..9eb3e10 100644 --- a/finetune.py +++ b/finetune.py @@ -28,6 +28,7 @@ out_path = this_dir / "finetune" / "tmp-trn" progress = 0 theme = gr.themes.Default() refresh_symbol = 'πŸ”„' +os.environ['TRAINER_TELEMETRY'] = '0' # Define the path to the modeldownload config file file modeldownload_config_file_path = this_dir / "modeldownload.json" @@ -470,10 +471,10 @@ def run_tts(lang, tts_text, speaker_audio_file): return "Speech generated !", out_path, speaker_audio_file -def get_available_voices(minimum_size_kb=1300): +def get_available_voices(minimum_size_kb=1200): voice_files = [ voice for voice in Path(f"{this_dir}/finetune/tmp-trn/wavs").glob("*.wav") - if voice.stat().st_size > minimum_size_kb * 1300 # Convert KB to bytes + if voice.stat().st_size > minimum_size_kb * 1200 # Convert KB to bytes ] return sorted([str(file) for file in voice_files]) # Return full path as string @@ -620,7 +621,7 @@ if __name__ == "__main__": ## Finetuning Information
### πŸŸ₯ Important Note ####      πŸŸ₯ finetune.py needs to be run from the /alltalk_tts/ folder. Don't move the location of this script. - ####      πŸŸ₯ Have you run AllTalk at least once? It needs to have downloaded the voice model, before we can finetune it. + ####      πŸŸ₯ Have you run AllTalk at least once? It needs to have downloaded+updated the voice model, before we can finetune it. ### 🟦 What you need to run finetuning ####      🟦 An Nvidia GPU. Tested on Windows with extended shared VRAM and training used about 16GB's total (which worked on a 12GB card). ####      🟦 I have not been able to test this on a GPU with less than 12GB of VRAM, so cannot say if it will work or how that would affect performance. @@ -839,6 +840,7 @@ if __name__ == "__main__": ## STEP 3 - Inference/Testing
### πŸŸ₯ Important Note ####      πŸŸ₯ This step will error if you are using TTS version 0.22.0. Please re-run pip install -r requirements_finetune.txt if it errors loading the model. + ####      πŸŸ₯ If you dont see multiple speaker reference files and you used more than 3 minutes of speech, try refreshing the page as it may not have loaded them correctly. ### 🟦 What you need to do ####      🟦 The model is now trained and you are at the testing stage. Hopefully all the dropdowns should be pre-populated now. ####      🟦 You need to Load Fine-tuned XTTS model and then select your Speaker Reference Audio. You can choose various Speaker Reference Audios to see which works best. @@ -941,7 +943,7 @@ if __name__ == "__main__": ### 🟦 What you need to do ####      🟦 The wav(s) you liked from Speaker Reference Audios are in /finetune/tmp-trn/wavs/ so copy the one(s) you selected to your /alltalk_tts/voices/ samples folder. ####      🟦 You can delete your original samples from inside of the /finetune/put-voice-samples-in-here/ folder. - ####      🟦 In the folder /finetune/tmp-trn/training/XTTS_FT(date here)/ you will find your best_model.pth, config.json and voice.json (also the last epoch training best_model_xxx.pth) + ####      🟦 In the folder /finetune/tmp-trn/training/XTTS_FT(date here)/ you will find your best_model.pth, config.json and vocab.json (also the last epoch training best_model_xxx.pth) ####      🟦 You can delete the last epoch training model file best_model_xxx.pth (the one with the numbers). ####      🟦 You will need to rename best_model.pth to model.pth. ####      🟦 You will close the Finetuning application and copy your 3 files listed above over the top of the existing model files inside your /alltalk_tts/models/xttsv2_2.0.2/ folder. From 558583b16f6a949ebc9af08d203db2e72952f890 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Sun, 24 Dec 2023 20:37:59 +0000 Subject: [PATCH 08/39] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 73b0c3c..66ef552 100644 --- a/README.md +++ b/README.md @@ -293,6 +293,8 @@ As mentioned you must have a small portion of the Nvidia CUDA Toolkit **11.8** i 12) When you have finished finetuning, the final tab will tell you what to do with your files and how to move your newly trained model to the correct location on disk. ## πŸ”΅πŸŸ’πŸŸ‘ DeepSpeed Installation Options +**NOTE**: You **DO NOT** need to set Text-generation-webUI's **--deepspeed** setting for AllTalk to be able to use DeepSpeed. These are two completely separate things and incorrectly setting that on Text-generation-webUI may cause other complications. + #### πŸ”΅ Linux Installation
Click to expand: Linux DeepSpeed installation From 52a7922e9885a728337aa9ac8fe5af9e2afd3e97 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 02:05:05 +0000 Subject: [PATCH 09/39] Add files via upload --- requirements_nvidia.txt | 2 +- requirements_other.txt | 2 +- tts_server.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/requirements_nvidia.txt b/requirements_nvidia.txt index d07a735..82579fd 100644 --- a/requirements_nvidia.txt +++ b/requirements_nvidia.txt @@ -10,4 +10,4 @@ requests>=2.31.0 tqdm>=4.66.1 importlib-metadata>=4.8.1 packaging>=23.2 -pydantic>=2.5.0 +pydantic>=1.10.13 diff --git a/requirements_other.txt b/requirements_other.txt index fdc8640..aad8a62 100644 --- a/requirements_other.txt +++ b/requirements_other.txt @@ -10,4 +10,4 @@ requests>=2.31.0 tqdm>=4.66.1 importlib-metadata>=4.8.1 packaging>=23.2 -pydantic>=2.5.0 +pydantic>=1.10.13 diff --git a/tts_server.py b/tts_server.py index 938bbc6..c458792 100644 --- a/tts_server.py +++ b/tts_server.py @@ -22,7 +22,6 @@ from fastapi.templating import Jinja2Templates from fastapi.staticfiles import StaticFiles from jinja2 import Template from contextlib import asynccontextmanager -from pydantic import field_validator ########################### #### STARTUP VARIABLES #### @@ -647,11 +646,10 @@ class JSONInput(BaseModel): autoplay: bool = Field(..., description="autoplay needs to be a true or false value.") autoplay_volume: float = Field(..., ge=0.1, le=1.0, description="autoplay_volume needs to be from 0.1 to 1.0") - @field_validator("autoplay_volume") @classmethod def validate_autoplay_volume(cls, value): if not (0.1 <= value <= 1.0): - raise ValidationError("Autoplay volume must be between 0.1 and 1.0") + raise ValueError("Autoplay volume must be between 0.1 and 1.0") return value From 0854544a47fda7b1d70454342869075d9dc52636 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 05:45:05 +0000 Subject: [PATCH 10/39] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 66ef552..0e94acc 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,19 @@ Other possibilities for this issue are: 11) You have built yourself a custom Python environment and something is funky with it. This is very hard to diagnose as its not a standard environment. You may want to updating text-generation-webui and re installing its requirements file (whichever one you use that comes down with text-generation-webui).
+#### 🟨 I think AllTalks requirements file has installed something another extension doesn't like +
+ Click to expand
+ +Ive paid very close attention to not impact the what Text-generation-webui is requesting on a factory install, nor over-write other extensions requirements (As best as I can account for). This is one of the requirements of submitting an extension to text-generation-webui. If you want to look at a comparison of a base text-generation-webui install (with cuda 12.1, though I based my requirements on cuda 11.8) you can find that comparison [here](https://github.com/erew123/alltalk_tts/issues/23) where you can see AllTalk is requesting the same as text-generation-webui or even lower version numbers (meaning AllTalk will not update them to a later version. + +The only one thing I cannot counter for is that the TTS engine downgrades Pandas data validator to 1.5.3 though its unlikely to cause any issues. You can upgrade it back to text-generation-webui default (december 2023) with `pip install pandas==2.1.4` when inside of the python environment. I have noticed no ill effects from it being a lower or higher version, as far as AllTalk goes. + +Other people are reporting issues with extensions not starting with errors about Pydantic e.g. `pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.5/migration/#basesettings-has-moved-to-pydantic-settings for more details.` + +Im not sure if the Pydantic version has been recently updated by the Text-generation-webui installer, but this is nothing to do with AllTalk. The other extension you are having an issue with needs to be updated to work with Pydantic 2.5.x. AllTalk was updated in mid december to work with 2.5.x +
+ #### 🟨 I activated DeepSpeed in the settings page, but I didnt install DeepSpeed yet and now I have issues starting up
Click to expand
From 1f425e6bac1fdaf5f03b24f5049b5d6c2b393e05 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 06:04:35 +0000 Subject: [PATCH 11/39] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0e94acc..719c7d4 100644 --- a/README.md +++ b/README.md @@ -207,13 +207,13 @@ Other possibilities for this issue are:
Click to expand
-Ive paid very close attention to not impact the what Text-generation-webui is requesting on a factory install, nor over-write other extensions requirements (As best as I can account for). This is one of the requirements of submitting an extension to text-generation-webui. If you want to look at a comparison of a base text-generation-webui install (with cuda 12.1, though I based my requirements on cuda 11.8) you can find that comparison [here](https://github.com/erew123/alltalk_tts/issues/23) where you can see AllTalk is requesting the same as text-generation-webui or even lower version numbers (meaning AllTalk will not update them to a later version. +Ive paid very close attention to not impact the what Text-generation-webui is requesting on a factory install, nor over-write other extensions requirements (As best as I can account for). This is one of the requirements of submitting an extension to text-generation-webui. If you want to look at a comparison of a base text-generation-webui install (with cuda 12.1, though I based my requirements on cuda 11.8) you can find that comparison [here](https://github.com/erew123/alltalk_tts/issues/23) where you can see AllTalk is requesting the same as text-generation-webui or even lower version numbers (meaning AllTalk will not update them to a later version). The only one thing I cannot counter for is that the TTS engine downgrades Pandas data validator to 1.5.3 though its unlikely to cause any issues. You can upgrade it back to text-generation-webui default (december 2023) with `pip install pandas==2.1.4` when inside of the python environment. I have noticed no ill effects from it being a lower or higher version, as far as AllTalk goes. -Other people are reporting issues with extensions not starting with errors about Pydantic e.g. `pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.5/migration/#basesettings-has-moved-to-pydantic-settings for more details.` +Other people are reporting issues with extensions not starting with errors about Pydantic e.g. ```pydantic.errors.PydanticImportError: BaseSettings` has been moved to the pydantic-settings package. See https://docs.pydantic.dev/2.5/migration/#basesettings-has-moved-to-pydantic-settings for more details.``` -Im not sure if the Pydantic version has been recently updated by the Text-generation-webui installer, but this is nothing to do with AllTalk. The other extension you are having an issue with needs to be updated to work with Pydantic 2.5.x. AllTalk was updated in mid december to work with 2.5.x +Im not sure if the Pydantic version has been recently updated by the Text-generation-webui installer, but this is nothing to do with AllTalk. The other extension you are having an issue with, need to be updated to work with Pydantic 2.5.x. AllTalk was updated in mid december to work with 2.5.x. I am not specifically condoning doing this, as it may have other knock on effects, but within the text-gen Python environment, you can use `pip install pydantic==2.5.0` or `pip install pydantic==1.10.13` to change the version of Pydantic installed.
#### 🟨 I activated DeepSpeed in the settings page, but I didnt install DeepSpeed yet and now I have issues starting up From c92aa435e59bdd26a5a04a674d2ac0c0e00c7921 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 09:37:39 +0000 Subject: [PATCH 12/39] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 719c7d4..07eefdf 100644 --- a/README.md +++ b/README.md @@ -207,9 +207,9 @@ Other possibilities for this issue are:
Click to expand
-Ive paid very close attention to not impact the what Text-generation-webui is requesting on a factory install, nor over-write other extensions requirements (As best as I can account for). This is one of the requirements of submitting an extension to text-generation-webui. If you want to look at a comparison of a base text-generation-webui install (with cuda 12.1, though I based my requirements on cuda 11.8) you can find that comparison [here](https://github.com/erew123/alltalk_tts/issues/23) where you can see AllTalk is requesting the same as text-generation-webui or even lower version numbers (meaning AllTalk will not update them to a later version). +Ive paid very close attention to **not** impact what Text-generation-webui is requesting on a factory install. This is one of the requirements of submitting an extension to Text-generation-webui. If you want to look at a comparison of a factory fresh text-generation-webui installed packages (with cuda 12.1, though AllTalk's requirements were set on cuda 11.8) you can find that comparison [here](https://github.com/erew123/alltalk_tts/issues/23). This comparison shows that AllTalk is requesting the same package version numbers as Text-generation-webui or even lower version numbers (meaning AllTalk will not update them to a later version). What other extensions do, I cant really account for that. -The only one thing I cannot counter for is that the TTS engine downgrades Pandas data validator to 1.5.3 though its unlikely to cause any issues. You can upgrade it back to text-generation-webui default (december 2023) with `pip install pandas==2.1.4` when inside of the python environment. I have noticed no ill effects from it being a lower or higher version, as far as AllTalk goes. +I will note that the TTS engine downgrades Pandas data validator to 1.5.3 though its unlikely to cause any issues. You can upgrade it back to text-generation-webui default (december 2023) with `pip install pandas==2.1.4` when inside of the python environment. I have noticed no ill effects from it being a lower or higher version, as far as AllTalk goes. This is also the same behaviour as the Coqui_tts extension that comes with Text-generation-webui. Other people are reporting issues with extensions not starting with errors about Pydantic e.g. ```pydantic.errors.PydanticImportError: BaseSettings` has been moved to the pydantic-settings package. See https://docs.pydantic.dev/2.5/migration/#basesettings-has-moved-to-pydantic-settings for more details.``` From dc9d3431152026cf59b85af53f1115d62bf8693f Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 21:09:39 +0000 Subject: [PATCH 13/39] Update uuid to avoid possible race condition file naming on short sentences could possibly have a race condition. set uuid as opposed to timestamp to avoid this outcome. --- script.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/script.py b/script.py index e325457..7b63446 100644 --- a/script.py +++ b/script.py @@ -618,11 +618,10 @@ def output_modifier(string, state): def get_output_filename(state): - # Check if character name exists and if not, just call it TTSOUT_ if "character_menu" in state: - return Path(f'{params["output_folder_wav"]}/{state["character_menu"]}_{int(time.time())}.wav').as_posix() + return Path(f'{params["output_folder_wav"]}/{state["character_menu"]}_{str(uuid.uuid4())[:8]}.wav').as_posix() else: - return Path(f'{params["output_folder_wav"]}/TTSOUT_{int(time.time())}.wav').as_posix() + return Path(f'{params["output_folder_wav"]}/TTSOUT_{str(uuid.uuid4())[:8]}.wav').as_posix() ############################################### From f5a811f0f86e3a022d0c7a6554c26247b062f8b4 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 21:11:02 +0000 Subject: [PATCH 14/39] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 07eefdf..15ef3b8 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ AllTalk is an updated version of the Coqui_tts extension for Text Generation web - πŸ”΄ [Future to-do list & Upcoming updates](https://github.com/erew123/alltalk_tts?#-future-to-do-list) #### Updates +Dec 25th - Applied a small update to avoid a possible race condition on file naming with small sentences when generating narrator/character speech. Please update if you are experiencing this. + The latest build (13 Dec 2023) has had the entire text filtering engine and narration engine rebuilt from scratch. It's highly complicated how its actually working, but the end result it a much clearer TTS output and much better control over the narrator option and how to handle text that isnt within quotes or asterisks. It does however mean you need to ensure your character card is set up correctly if using the narrator function. Details are below in the installation notes. DeepSpeed **v11.2** can be installed within the **default text-generation-webui Python 3.11 environment**. Installs in custom Python environments are possible, but can be more complicated. Instructions [here](https://github.com/erew123/alltalk_tts##deepspeed-installation-options) (or scroll down). From be9862d0b04310c78f66bc61c45b9db41b4ec941 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 21:15:54 +0000 Subject: [PATCH 15/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15ef3b8..3395b4b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ AllTalk is an updated version of the Coqui_tts extension for Text Generation web - πŸ”΄ [Future to-do list & Upcoming updates](https://github.com/erew123/alltalk_tts?#-future-to-do-list) #### Updates -Dec 25th - Applied a small update to avoid a possible race condition on file naming with small sentences when generating narrator/character speech. Please update if you are experiencing this. +Dec 25th - Applied a small update to avoid a possible race condition on file naming with small sentences when generating narrator/character speech. Please update if you are experiencing missing small bits of missing audio on narrator/character. The latest build (13 Dec 2023) has had the entire text filtering engine and narration engine rebuilt from scratch. It's highly complicated how its actually working, but the end result it a much clearer TTS output and much better control over the narrator option and how to handle text that isnt within quotes or asterisks. It does however mean you need to ensure your character card is set up correctly if using the narrator function. Details are below in the installation notes. From 5bed68a9634a137ec828e5a767fc54fdffecf09e Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Mon, 25 Dec 2023 21:53:40 +0000 Subject: [PATCH 16/39] minor update to standard voice naming. --- script.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/script.py b/script.py index 7b63446..30a3dc0 100644 --- a/script.py +++ b/script.py @@ -501,7 +501,7 @@ def output_modifier(string, state): if process_lock.acquire(blocking=False): try: if params["narrator_enabled"]: - # print(original_string) + #print(original_string) # Do Some basic stripping and remove any double CR's processed_string = ( original_string @@ -522,11 +522,11 @@ def output_modifier(string, state): .replace('"', '"<') ) #capturing another outlier in inital character paragraph - # print("processed string 1 is:", processed_string) + #print("processed string 1 is:", processed_string) processed_string = processed_string.replace('"<. *', '"< *"') processed_string = processed_string.replace('< *"', '< *') processed_string = processed_string.replace('. *', '< *') - # print("processed string 2 is:", processed_string) + #print("processed string 2 is:", processed_string) # Set up a tracking of the individual wav files. audio_files_all_paragraphs = [] # Split the line using " and ".* " (so end of sentences, leaving special characters added to the start of all OTHER sentences, bar possibly the first one if its starting with a * @@ -541,11 +541,11 @@ def output_modifier(string, state): if '<' in part and '< *' not in part and '<*' not in part and '< *' not in part and '< ' not in part and '< ' not in part: cleaned_part = html.unescape(part.replace('<', '')) voice_to_use = params["voice"] - #Narrator will always be an * or < with an * a position or two after it. + #Narrator will always be an * or < with an * a position or two after it. elif '<*' in part or '< *' in part or '< *' in part or '*' in part: cleaned_part = html.unescape(part.replace('<*', '').replace('< *', '').replace('< *', '').replace('*', '')) voice_to_use = params["narrator_voice"] - #If the other two dont capture it, aka, the AI gave no * or " on the line, use non_quoted_text_is aka user interface, user can choose Char or Narrator + #If the other two dont capture it, aka, the AI gave no * or " on the line, use non_quoted_text_is aka user interface, user can choose Char or Narrator elif non_quoted_text_is: cleaned_part = html.unescape(part.replace('< ', '').replace('< ', '').replace('< ', '')) voice_to_use = params["voice"] @@ -576,9 +576,14 @@ def output_modifier(string, state): ) cleaned_part = html.unescape(processed_string) # Process the part and give it a non-character name if being used vai API or standalone. - output_filename = get_output_filename(state) + if "character_menu" in state: + output_file = Path(f'{params["output_folder_wav"]}/{state["character_menu"]}_{int(time.time())}.wav') + else: + output_file = Path(f'{params["output_folder_wav"]}/TTSOUT_{int(time.time())}.wav') + output_file_str = output_file.as_posix() + output_file = get_output_filename(state) generate_response = send_generate_request( - cleaned_part, params["voice"], language_code, output_filename + cleaned_part, params["voice"], language_code, output_file_str ) audio_path = generate_response.get("data", {}).get("audio_path") final_output_file = audio_path From 2ea6cb6304f2baca027b80c65cc498aee487d562 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 06:23:26 +0000 Subject: [PATCH 17/39] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3395b4b..06dc242 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ AllTalk is an updated version of the Coqui_tts extension for Text Generation web #### Updates Dec 25th - Applied a small update to avoid a possible race condition on file naming with small sentences when generating narrator/character speech. Please update if you are experiencing missing small bits of missing audio on narrator/character. +####     πŸ”„ **Minor updates/bug fixes list** can be found [here](https://github.com/erew123/alltalk_tts/issues/25) + The latest build (13 Dec 2023) has had the entire text filtering engine and narration engine rebuilt from scratch. It's highly complicated how its actually working, but the end result it a much clearer TTS output and much better control over the narrator option and how to handle text that isnt within quotes or asterisks. It does however mean you need to ensure your character card is set up correctly if using the narrator function. Details are below in the installation notes. DeepSpeed **v11.2** can be installed within the **default text-generation-webui Python 3.11 environment**. Installs in custom Python environments are possible, but can be more complicated. Instructions [here](https://github.com/erew123/alltalk_tts##deepspeed-installation-options) (or scroll down). @@ -147,6 +149,7 @@ Assuming its all working fine and you are happy, you can delete the old alltalk_ |![image](https://github.com/erew123/alltalk_tts/assets/35898566/68edc968-bdd2-4f98-9d56-b9ca40decf26) | ![image](https://github.com/erew123/alltalk_tts/assets/35898566/eb5e617b-2345-418d-8267-a9d30f705a10) | ## 🟨 Help with problems +####      πŸ”„ **Minor updates/bug fixes list** can be found [here](https://github.com/erew123/alltalk_tts/issues/25) #### 🟨 How to make a diagnostics report file
From 97f0d6441a144cfe061b8ec87dc7088dd989ab8d Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 07:30:30 +0000 Subject: [PATCH 18/39] Improved links in Documentation Added links to the minor bugs/known issues on gthub --- tts_server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tts_server.py b/tts_server.py index c458792..9d6e717 100644 --- a/tts_server.py +++ b/tts_server.py @@ -1052,6 +1052,12 @@ simple_webpage = """

AllTalk is a web interface, based around the Coqui TTS voice cloning/speech generation system. To generate TTS, you can use the provided gradio interface or interact with the server using JSON/CURL commands. 

Note: When loading up a new character in Text generation webUI it may look like nothing is happening for 20-30 seconds. Its actually processing the introduction section (greeting message) of the text and once that is completed, it will appear. You can see the activity occuring in the console window. Refreshing the page multiple times will try force the TTS engine to keep re-generating the text, so please just wait and check the console if needed.

Note: Ensure that your RP character card has asterisks around anything for the narration and double quotes around anything spoken. There is a complication ONLY with the greeting card so, ensuring it has the correct use of quotes and asterisks will help make sure that the greeting card sounds correct. I will aim to address this issue in a future update. In Text-generation-webUI parameters menu > character tab > greeting make sure that anything in there that is the narrator is in asterisks and anything spoken is in double quotes, then hit the save (πŸ’Ύ) button.

+

AllTalk Minor Bug Fixes Changelog & Known issues

+

If I squash any minor bugs or find any issues, I will try to apply an update asap. If you think something isnt working correctly or you have a problem, check these two links below first.

+

AllTalk
Github link here
Update instructions link here
Help and issues link here

Text generation webUI
Web interface link here
Documentation link here

Back to top of page

Server Information

From 9fae4692e3758a94af4a202b73a2a8d52c142052 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 08:03:24 +0000 Subject: [PATCH 19/39] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 06dc242..2c5e71a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ This has been tested on the current Dec 2023 release of Text generation webUI. I `cd text-generation-webui` 2) Start the Text generation webUI Python environment for your OS:

-`cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat` +`cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat`

+[Click here to see what your command line should look like when you load the Text-generation-webui Python environment](https://github.com/erew123/alltalk_tts/issues/25#issuecomment-1869344442) 3) Move into your extensions folder:

`cd extensions` From f181c06f8988d1ff99efb9e47b3ce40be8962b20 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 10:02:17 +0000 Subject: [PATCH 20/39] Update README.md Added a video link to show people how to install AllTalk. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2c5e71a..b318746 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ DeepSpeed **v11.2** can be installed within the **default text-generation-webui ## 🟩 Installation on Text generation web UI This has been tested on the current Dec 2023 release of Text generation webUI. If you have not updated it for a while, you may wish to update Text generation webUI, [instructions here](https://github.com/oobabooga/text-generation-webui?tab=readme-ov-file#how-to-install) +If you want to watch a video of how to do the below [link here](https://youtu.be/9BPKuwaav5w) + 1) In a command prompt/terminal window you need to move into your Text generation webUI folder:

`cd text-generation-webui` From ac9ce144a01df6be30a2c4fc9dea71b3e82aac1b Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:47:24 +0000 Subject: [PATCH 21/39] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b318746..1c94eeb 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ If you want to watch a video of how to do the below [link here](https://youtu.be 1) In a command prompt/terminal window you need to move into your Text generation webUI folder:

`cd text-generation-webui` -2) Start the Text generation webUI Python environment for your OS:

+2) Start the Text generation webUI Python environment for your OS **(VERY IMPORTANT)**:

`cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat`

[Click here to see what your command line should look like when you load the Text-generation-webui Python environment](https://github.com/erew123/alltalk_tts/issues/25#issuecomment-1869344442) @@ -60,7 +60,7 @@ If you want to watch a video of how to do the below [link here](https://youtu.be 7) **(Optional DeepSpeed)** If you have an Nvidia Graphics card on a system running Linux or Windows and wish to use **DeepSpeed** please follow these instructions [here](https://github.com/erew123/alltalk_tts?#-deepspeed-installation-options). **However**, I would highly reccommend before you install DeepSpeed, you start text-generation-webui up, confirm AllTalk starts correctly and everything is working, as DeepSpeed can add another layer of complications troubleshooting any potential start-up issues. If necessary you can `pip uninstall deepspeed`. -8) You can now start move back to the main Text generation webUI folder `cd ..` (a few times), start Text generation webUI (`start_windows.bat`,`./start_linux.sh`, `start_macos.sh` or `start_wsl.bat`) and load the AllTalk extension in the Text generation webUI **session** tab. +8) You can now start move back to the main Text generation webUI folder `cd ..` (a few times), start Text generation webUI **(VERY IMPORTANT)** (`start_windows.bat`,`./start_linux.sh`, `start_macos.sh` or `start_wsl.bat`) and load the AllTalk extension in the Text generation webUI **session** tab. 9) Please read the note below about start-up times and also the note about ensuring your character cards are set up [correctly](https://github.com/erew123/alltalk_tts#the-one-thing-i-cant-easily-work-around) From e775cef5bd67a60b10d7187bd5a6ad8d7b4b316f Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:19:21 +0000 Subject: [PATCH 22/39] Update README.md --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1c94eeb..b04012a 100644 --- a/README.md +++ b/README.md @@ -36,14 +36,13 @@ DeepSpeed **v11.2** can be installed within the **default text-generation-webui ## 🟩 Installation on Text generation web UI This has been tested on the current Dec 2023 release of Text generation webUI. If you have not updated it for a while, you may wish to update Text generation webUI, [instructions here](https://github.com/oobabooga/text-generation-webui?tab=readme-ov-file#how-to-install) -If you want to watch a video of how to do the below [link here](https://youtu.be/9BPKuwaav5w) +If you want to watch a video of how to do the below [link here](https://youtu.be/9BPKuwaav5w) 1) In a command prompt/terminal window you need to move into your Text generation webUI folder:

`cd text-generation-webui` -2) Start the Text generation webUI Python environment for your OS **(VERY IMPORTANT)**:

-`cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat`

-[Click here to see what your command line should look like when you load the Text-generation-webui Python environment](https://github.com/erew123/alltalk_tts/issues/25#issuecomment-1869344442) +2) Start the Text generation webUI Python environment for your OS:

+`cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat`

Loading Text-generation-webui's Python Environment is $\textcolor{red}{\textsf{VERY IMPORTANT}}$. If you are uncertain what a loaded Python environment looks like, image [here](https://github.com/erew123/alltalk_tts/issues/25#issuecomment-1869344442) and video [here](https://www.youtube.com/watch?v=9BPKuwaav5w) 3) Move into your extensions folder:

`cd extensions` @@ -60,11 +59,11 @@ If you want to watch a video of how to do the below [link here](https://youtu.be 7) **(Optional DeepSpeed)** If you have an Nvidia Graphics card on a system running Linux or Windows and wish to use **DeepSpeed** please follow these instructions [here](https://github.com/erew123/alltalk_tts?#-deepspeed-installation-options). **However**, I would highly reccommend before you install DeepSpeed, you start text-generation-webui up, confirm AllTalk starts correctly and everything is working, as DeepSpeed can add another layer of complications troubleshooting any potential start-up issues. If necessary you can `pip uninstall deepspeed`. -8) You can now start move back to the main Text generation webUI folder `cd ..` (a few times), start Text generation webUI **(VERY IMPORTANT)** (`start_windows.bat`,`./start_linux.sh`, `start_macos.sh` or `start_wsl.bat`) and load the AllTalk extension in the Text generation webUI **session** tab. +8) You can now start move back to the main Text generation webUI folder `cd ..` (a few times), start Text generation webUI (`start_windows.bat`,`./start_linux.sh`, `start_macos.sh` or `start_wsl.bat`) and load the AllTalk extension in the Text generation webUI **session** tab.

Starting Text-generation-webui with its correct start-up script is $\textcolor{red}{\textsf{VERY IMPORTANT}}$. -9) Please read the note below about start-up times and also the note about ensuring your character cards are set up [correctly](https://github.com/erew123/alltalk_tts#the-one-thing-i-cant-easily-work-around) +10) Please read the note below about start-up times and also the note about ensuring your character cards are set up [correctly](https://github.com/erew123/alltalk_tts#the-one-thing-i-cant-easily-work-around) -10) Some extra voices downloadable [here](https://drive.google.com/file/d/1bYdZdr3L69kmzUN3vSiqZmLRD7-A3M47/view?usp=drive_link) +11) Some extra voices downloadable [here](https://drive.google.com/file/d/1bYdZdr3L69kmzUN3vSiqZmLRD7-A3M47/view?usp=drive_link) #### 🟩 Other installation notes On first startup, AllTalk will download the Coqui XTTSv2 2.0.2 model to its **models** folder (1.8GB space required). Check the command prompt/terminal window if you want to know what its doing. After it says "Model Loaded" the Text generation webUI is usually available on its IP address a few seconds later, for you to connect to in your browser. From 7ad92e7f5d7809c4001b57b8715798b76ec3be6c Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:28:28 +0000 Subject: [PATCH 23/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b04012a..13b0a5e 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ If you want to watch a video of how to do the below [link here](https://youtu.be 5) Move into the **alltalk_tts** folder:

`cd alltalk_tts` -6) Install the requirements that are correct for your machine:

+6) Install one of the two requirements files. Whichever one of the two is correct for your machine type:

**Nvidia graphics card machines** - `pip install -r requirements_nvidia.txt`

**Other machines (mac, amd etc)** - `pip install -r requirements_other.txt` From 26414d4925a3d23bc128286c5c5987792e4b695a Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:30:40 +0000 Subject: [PATCH 24/39] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 13b0a5e..b71fb0b 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ If you want to watch a video of how to do the below [link here](https://youtu.be 1) In a command prompt/terminal window you need to move into your Text generation webUI folder:

`cd text-generation-webui` -2) Start the Text generation webUI Python environment for your OS:

+2) Start the Text generation webUI Python environment for your OS with whichever **one** of the below is correct for your OS:

`cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat`

Loading Text-generation-webui's Python Environment is $\textcolor{red}{\textsf{VERY IMPORTANT}}$. If you are uncertain what a loaded Python environment looks like, image [here](https://github.com/erew123/alltalk_tts/issues/25#issuecomment-1869344442) and video [here](https://www.youtube.com/watch?v=9BPKuwaav5w) 3) Move into your extensions folder:

@@ -59,7 +59,7 @@ If you want to watch a video of how to do the below [link here](https://youtu.be 7) **(Optional DeepSpeed)** If you have an Nvidia Graphics card on a system running Linux or Windows and wish to use **DeepSpeed** please follow these instructions [here](https://github.com/erew123/alltalk_tts?#-deepspeed-installation-options). **However**, I would highly reccommend before you install DeepSpeed, you start text-generation-webui up, confirm AllTalk starts correctly and everything is working, as DeepSpeed can add another layer of complications troubleshooting any potential start-up issues. If necessary you can `pip uninstall deepspeed`. -8) You can now start move back to the main Text generation webUI folder `cd ..` (a few times), start Text generation webUI (`start_windows.bat`,`./start_linux.sh`, `start_macos.sh` or `start_wsl.bat`) and load the AllTalk extension in the Text generation webUI **session** tab.

Starting Text-generation-webui with its correct start-up script is $\textcolor{red}{\textsf{VERY IMPORTANT}}$. +8) You can now start move back to the main Text generation webUI folder `cd ..` (a few times), start Text generation webUI with whichever **one** of the startup scripts is correct for your OS (`start_windows.bat`,`./start_linux.sh`, `start_macos.sh` or `start_wsl.bat`) and load the AllTalk extension in the Text generation webUI **session** tab.

Starting Text-generation-webui with its correct start-up script is $\textcolor{red}{\textsf{VERY IMPORTANT}}$. 10) Please read the note below about start-up times and also the note about ensuring your character cards are set up [correctly](https://github.com/erew123/alltalk_tts#the-one-thing-i-cant-easily-work-around) From 47758c4aebaf08f946e490601798c795f312fe72 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Tue, 26 Dec 2023 18:58:06 +0000 Subject: [PATCH 25/39] Updated diagnostics Pulls Conda and Python environment details. --- diagnostics.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/diagnostics.py b/diagnostics.py index 6ede8fa..7688698 100644 --- a/diagnostics.py +++ b/diagnostics.py @@ -6,6 +6,7 @@ try: import torch import os # Import the os module import re + import sys import glob import textwrap import packaging.version @@ -17,7 +18,7 @@ except ImportError as e: print(f"\033[91mError importing module: {e}\033[0m\n") print("\033[94mPlease ensure you started the Text-generation-webUI Python environment with either\033[0m") print("\033[92mcmd_linux.sh\033[0m, \033[92mcmd_windows.bat\033[0m, \033[92mcmd_macos.sh\033[0m, or \033[92mcmd_wsl.bat\033[0m") - print("\033[94mand then try running the diagnostics again.\033[0m") + print("\033[94mfrom the text-generation-webui directory, and then try running the diagnostics again.\033[0m") exit(1) try: @@ -110,6 +111,14 @@ def log_system_info(): # Package versions using importlib_metadata package_versions = {d.metadata['Name']: d.version for d in distributions()} + # Python environment information + python_executable = sys.executable + python_version_info = sys.version_info + python_virtual_env = os.environ.get('VIRTUAL_ENV', 'N/A') + + # Conda environment information + conda_env = os.environ.get('CONDA_DEFAULT_ENV', 'N/A') + # Compare with requirements file requirements_file = get_requirements_file() if requirements_file: @@ -134,12 +143,16 @@ def log_system_info(): # Log and print information logging.info(f"OS Version: {os_version}") - logging.info(f"Note: Windows 11 build is 10.x.22xxx") - logging.info(f"Python Version: {python_version}") + logging.info(f"Note: Windows 11 will list as build is 10.x.22xxx") logging.info(f"Torch Version: {torch_version}") logging.info(f"System RAM: {system_ram}") logging.info(f"CUDA_HOME: {cuda_home}") logging.info(f"Port Status: {port_status}") + logging.info(f"Python Version: {platform.python_version()}") + logging.info(f"Python Version Info: {python_version_info}") + logging.info(f"Python Executable: {python_executable}") + logging.info(f"Python Virtual Environment: {python_virtual_env} (Should be N/A when in Text-generation-webui Conda Python environment)") + logging.info(f"Conda Environment: {conda_env}") if required_packages: # Check if the dictionary is not empty logging.info("Package Versions:") max_package_length = max(len(package) for package in required_packages.keys()) @@ -153,12 +166,16 @@ def log_system_info(): # Print to screen print(f"\n\033[94mOS Version:\033[0m \033[92m{os_version}\033[0m") - print(f"\033[94mOS Ver note:\033[0m \033[92mWindows 11 build is 10.x.22xxx\033[0m") + print(f"\033[94mOS Ver note:\033[0m \033[92m(Windows 11 will say build is 10.x.22xxx)\033[0m") print(f"\033[94mCUDA_HOME:\033[0m \033[92m{cuda_home}\033[0m") print(f"\033[94mSystem RAM:\033[0m \033[92m{system_ram}\033[0m") print(f"\033[94mPort Status:\033[0m \033[92m{port_status}\033[0m") print(f"\033[94mTorch Version:\033[0m \033[92m{torch_version}\033[0m") - print(f"\033[94mPython Version:\033[0m \033[92m{python_version}\033[0m") + print(f"\033[94mPython Version:\033[0m \033[92m{platform.python_version()}\033[0m") + print(f"\033[94mPython Version Info:\033[0m \033[92m{python_version_info}\033[0m") + print(f"\033[94mPython Executable:\033[0m \033[92m{python_executable}\033[0m") + print(f"\033[94mPython Virtual Environment:\033[0m \033[92m{python_virtual_env}\033[0m (Should be N/A when in Text-generation-webui Conda Python environment)") + print(f"\033[94mConda Environment:\033[0m \033[92m{conda_env}\033[0m") if required_packages: # Check if the dictionary is not empty print("\033[94m\nRequirements file package comparison:\033[0m") max_package_length = max(len(package) for package in required_packages.keys()) From 607dc89be503b73ad214a8bfa3185b704f66ea6a Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Wed, 27 Dec 2023 04:44:44 +0000 Subject: [PATCH 26/39] Update README.md Added a section on Running AllTalk as a standalone --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index b71fb0b..9404074 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ AllTalk is an updated version of the Coqui_tts extension for Text Generation web - 🟨 [Help with problems](https://github.com/erew123/alltalk_tts?#-help-with-problems) - ⚫ [Finetuning a model](https://github.com/erew123/alltalk_tts?#-finetuning-a-model) - πŸ”΅πŸŸ’πŸŸ‘ [DeepSpeed Installation (Windows & Linux)](https://github.com/erew123/alltalk_tts?#-deepspeed-installation-options) +- 🟦 [Running AllTalk as a standalone app](https://github.com/erew123/alltalk_tts?#-running-alltalk-as-a-standalone-app) - 🟠 [API Suite and JSON-CURL](https://github.com/erew123/alltalk_tts?#-api-suite-and-json-curl) - πŸ”΄ [Future to-do list & Upcoming updates](https://github.com/erew123/alltalk_tts?#-future-to-do-list) @@ -465,6 +466,29 @@ def get_shm_size(): **Removal** - If it became necessary to uninstall DeepSpeed, you can do so with `cmd_windows.bat` and then `pip uninstall deepspeed`

+## 🟦 Running AllTalk as a standalone app +AllTalk will run as a standalone app, as long as you install its requirements files into whatever Python environment you are using. You can follow the steps to install the AllTalk's requirements into whatever Python environment you wish. Because I dont know what Python environment you are wanting to use, I can only give you a loose set of installation instructions. + +#### 🟦 (Option 1) I already have AllTalk installed as an extension of Text-generation-webui +If you already have AllTalk as a extension of Text-generation-webui, and wish to run it as standalone, load Text-generation-webui's Python environment `cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat`, move into the AllTalk folder `cd extensions` > `cd alltalk_tts` and start AllTalk with `python script.py`. There is nothing beyond this you would need to do. + +#### 🟦 (Option 2) I wish to do a custom install of AllTalk +1) In your chosen disk location git clone this repository:

+`git clone https://github.com/erew123/alltalk_tts` + +2) Move into the **alltalk_tts** folder:

+`cd alltalk_tts` + +3) If you have a custom Python environment, now is the time to load it! + +4) Install one of the two requirements files. Whichever one of the two is correct for your machine type:

+**Nvidia graphics card machines** - `pip install -r requirements_nvidia.txt`

+**Other machines (mac, amd etc)** - `pip install -r requirements_other.txt` + +5) Start AllTalk with `python script.py` + +Deepspeed and other such things can be installed. Please read the relevant instructions for those items, however, make the relevant changes to load your correct Python environment when installing any requirements files and starting AllTalk. + ## 🟠 API Suite and JSON-CURL ### 🟠Overview The Text-to-Speech (TTS) Generation API allows you to generate speech from text input using various configuration options. This API supports both character and narrator voices, providing flexibility for creating dynamic and engaging audio content. From f83e7c3b4efa4557775a874755aef523e7e1d3de Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Wed, 27 Dec 2023 06:00:30 +0000 Subject: [PATCH 27/39] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9404074..288d508 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,6 @@ Dec 25th - Applied a small update to avoid a possible race condition on file nam ####     πŸ”„ **Minor updates/bug fixes list** can be found [here](https://github.com/erew123/alltalk_tts/issues/25) -The latest build (13 Dec 2023) has had the entire text filtering engine and narration engine rebuilt from scratch. It's highly complicated how its actually working, but the end result it a much clearer TTS output and much better control over the narrator option and how to handle text that isnt within quotes or asterisks. It does however mean you need to ensure your character card is set up correctly if using the narrator function. Details are below in the installation notes. - -DeepSpeed **v11.2** can be installed within the **default text-generation-webui Python 3.11 environment**. Installs in custom Python environments are possible, but can be more complicated. Instructions [here](https://github.com/erew123/alltalk_tts##deepspeed-installation-options) (or scroll down). - ## 🟩 Installation on Text generation web UI This has been tested on the current Dec 2023 release of Text generation webUI. If you have not updated it for a while, you may wish to update Text generation webUI, [instructions here](https://github.com/oobabooga/text-generation-webui?tab=readme-ov-file#how-to-install) @@ -469,6 +465,8 @@ def get_shm_size(): ## 🟦 Running AllTalk as a standalone app AllTalk will run as a standalone app, as long as you install its requirements files into whatever Python environment you are using. You can follow the steps to install the AllTalk's requirements into whatever Python environment you wish. Because I dont know what Python environment you are wanting to use, I can only give you a loose set of installation instructions. +Please note, at time of writing, the TTS engine requires Python **3.9.x** to **3.11.x** [TTS Engine details here](https://pypi.org/project/TTS/) + #### 🟦 (Option 1) I already have AllTalk installed as an extension of Text-generation-webui If you already have AllTalk as a extension of Text-generation-webui, and wish to run it as standalone, load Text-generation-webui's Python environment `cmd_windows.bat`, `./cmd_linux.sh`, `cmd_macos.sh` or `cmd_wsl.bat`, move into the AllTalk folder `cd extensions` > `cd alltalk_tts` and start AllTalk with `python script.py`. There is nothing beyond this you would need to do. From 94f5b781cca476977e131182691192bfcb957a4c Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Wed, 27 Dec 2023 06:08:10 +0000 Subject: [PATCH 28/39] Update Standalone API - race condition fix Applies the same race condition fix for narrator/character that potentially existed, but for the standalone mode API. Will have zero effect for anyone not using the API --- tts_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tts_server.py b/tts_server.py index 9d6e717..d5f3e73 100644 --- a/tts_server.py +++ b/tts_server.py @@ -624,6 +624,7 @@ async def get_audio(filename: str): ######################## import html import re +import uuid import numpy as np import soundfile as sf from typing import Union, Dict @@ -802,7 +803,7 @@ async def tts_generate( print("ELSE - NARRATOR\n") cleaned_part = html.unescape(part.replace('< ', '').replace('< ', '').replace('< ', '')) voice_to_use = narrator_voice_gen - output_file = this_dir / "outputs" / f"{output_file_name}_{int(time.time())}_{i}.wav" + output_file = this_dir / "outputs" / f"{output_file_name}_{uuid.uuid4()}_{int(time.time())}_{i}.wav" output_file_str = output_file.as_posix() await generate_audio(cleaned_part, voice_to_use, language, output_file_str) audio_path = output_file_str From a34cbfdd553cb97cdfdf1e9fd405119a9cd905f5 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Wed, 27 Dec 2023 06:43:28 +0000 Subject: [PATCH 29/39] Made Settings link more visble Updated the visibility of the settings & documentation page within Text-gen-webui interface. Minor built in documentation update. --- script.py | 2 +- tts_server.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script.py b/script.py index 30a3dc0..0873aa7 100644 --- a/script.py +++ b/script.py @@ -786,7 +786,7 @@ def ui(): ) tts_radio_buttons_play = gr.HTML(visible=False) explanation_text = gr.HTML( - f"

NOTE: Switching Model Type, Low VRAM & DeepSpeed, each takes 15 seconds. Each TTS generation method has a slightly different sound. DeepSpeed checkbox is only visible if DeepSpeed is present. Readme & Settings: http://{params['ip_address']}:{params['port_number']}" + f"

βš™οΈ Click here for the Settings page, help & instructionsβš™οΈ
NOTE: Switching Model Type, Low VRAM & DeepSpeed, each takes 15 seconds. Each TTS generation method has a slightly different sound. DeepSpeed checkbox is only visible if DeepSpeed is installed on your system." ) with gr.Row(): diff --git a/tts_server.py b/tts_server.py index d5f3e73..61fb07b 100644 --- a/tts_server.py +++ b/tts_server.py @@ -1158,7 +1158,7 @@ simple_webpage = """

Save your generated wav file in the /alltalk_tts/voices/ folder.

Its worth mentioning that using AI generated audio clips may introduce unwanted sounds as its already a copy/simulation of a voice.

Why doesnt it sound like XXX Person?

-

The reasons can be that you:

+

Maybe you might be interested in trying Finetuning of the model. Otherwise, the reasons can be that you:

## 🟫 Screenshots -|![image](https://github.com/erew123/alltalk_tts/assets/35898566/4ca9b4c7-60ce-4ac6-82e5-fd1989b84644) | ![image](https://github.com/erew123/alltalk_tts/assets/35898566/548619c8-5f1b-47d0-a73d-54d2fee3f3db) | +|![image](https://github.com/erew123/alltalk_tts/assets/35898566/15c6ba0b-e6b0-4570-8253-b920dd76174d) | ![image](https://github.com/erew123/alltalk_tts/assets/35898566/548619c8-5f1b-47d0-a73d-54d2fee3f3db) | |:---:|:---:| |![image](https://github.com/erew123/alltalk_tts/assets/35898566/b0e13dba-c6b1-4ab7-845d-244ac1158330) | ![image](https://github.com/erew123/alltalk_tts/assets/35898566/e35e987c-543a-486b-b4fb-ee6ebe6f59c6) | |![image](https://github.com/erew123/alltalk_tts/assets/35898566/68edc968-bdd2-4f98-9d56-b9ca40decf26) | ![image](https://github.com/erew123/alltalk_tts/assets/35898566/eb5e617b-2345-418d-8267-a9d30f705a10) | From 1a2b8571d036f24d8b875e99c6767bb26caccb22 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:05:46 +0000 Subject: [PATCH 31/39] Updated diagnostics to include Path Now includes both Python and environment variables PATH search locations. --- diagnostics.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/diagnostics.py b/diagnostics.py index 7688698..ca5466a 100644 --- a/diagnostics.py +++ b/diagnostics.py @@ -119,6 +119,10 @@ def log_system_info(): # Conda environment information conda_env = os.environ.get('CONDA_DEFAULT_ENV', 'N/A') + # Get Path environment information + search_path = sys.path + path_env = os.environ.get('PATH', 'N/A') + # Compare with requirements file requirements_file = get_requirements_file() if requirements_file: @@ -153,8 +157,14 @@ def log_system_info(): logging.info(f"Python Executable: {python_executable}") logging.info(f"Python Virtual Environment: {python_virtual_env} (Should be N/A when in Text-generation-webui Conda Python environment)") logging.info(f"Conda Environment: {conda_env}") + logging.info("\nPython Search Path:") + for path in search_path: + logging.info(f" {path}") + logging.info("\nOS PATH Environment Variable:") + for path in path_env.split(';'): + logging.info(f" {path}") if required_packages: # Check if the dictionary is not empty - logging.info("Package Versions:") + logging.info("\nPackage Versions:") max_package_length = max(len(package) for package in required_packages.keys()) for package_name, (operator, required_version) in required_packages.items(): installed_version = installed_packages.get(package_name, 'Not installed') @@ -176,6 +186,12 @@ def log_system_info(): print(f"\033[94mPython Executable:\033[0m \033[92m{python_executable}\033[0m") print(f"\033[94mPython Virtual Environment:\033[0m \033[92m{python_virtual_env}\033[0m (Should be N/A when in Text-generation-webui Conda Python environment)") print(f"\033[94mConda Environment:\033[0m \033[92m{conda_env}\033[0m") + print(f"\n\033[94mPython Search Path:\033[0m") + for path in search_path: + print(f" {path}") + print(f"\n\033[94mOS Search PATH Environment Variable:\033[0m") + for path in path_env.split(';'): + print(f" {path}") if required_packages: # Check if the dictionary is not empty print("\033[94m\nRequirements file package comparison:\033[0m") max_package_length = max(len(package) for package in required_packages.keys()) From 9f033e4654c4e9698b112adf9634740f18eeebe4 Mon Sep 17 00:00:00 2001 From: Ryan Bruels Date: Thu, 28 Dec 2023 10:28:20 -0800 Subject: [PATCH 32/39] A few changes/clarifications in the fine-tuning sections --- README.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9adadcf..d4407cc 100644 --- a/README.md +++ b/README.md @@ -271,17 +271,23 @@ I would suggest that if its in an interview format, you cut out the interviewer #### ⚫ Important requirements CUDA 11.8 As mentioned you must have a small portion of the Nvidia CUDA Toolkit **11.8** installed. Not higher or lower versions. Specifically **11.8**. You do not have to uninstall any other versions, change any graphics drivers, reinstall torch or anything like that. To keep the download+install as small as possible, you will need to: - Download the **xxx (network)** install of the Nvidia Cuda Toolkit 11.8 from [here](https://developer.nvidia.com/cuda-11-8-0-download-archive) -- When you run the installation, select **Custom Advanced** as your installation type. Uncheck `CUDA`, `Other Components` and `Driver Components` at the top then expand `CUDA` > `Development` > `Compiler` > and select `nvcc` then expand `Libraries` and select `CUBLAS` -- Back at the top of `CUDA` expand `Runtime` > `Libraries` and select `CUBLAS`. You can now next through the install. +- Run the installer. At minimum, you need to [minimally] install the `nvcc` compiler and the `CUBLAS` development and runtime libraries: + - Select **Custom Advanced** as your installation type. + - Uncheck all the checkboxes in the list. + - Now check the following elements: + - `CUDA` > `Development` > `Compiler` > `nvcc` + - `CUDA` > `Development` > `Compiler` > `Libraries` > `CUBLAS` + - `CUDA` > `Runtime` > `Libraries` > `CUBLAS` + - You can now proceed through the install. - When that has installed, open a terminal/command prompt and type `nvcc --version`. If it reports back `Cuda compilation tools, release 11.8.` you are good to go. **Specifically, 11.8**. If not continue to the next step. -- For both Windows an Linux, you will need to ensure that `nvcc` and the 11.8 cuda library files are in your environments search path. You can undo the changes below after finetuning if you prefer.

- **Windows** - Edit the Windows PATH environment variable and add `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin`

- **Linux** - The path may be different depending on what flavour of Linux you are running, so you may need to seek out specific instructions on the internet. Generic paths **may** be:
- `export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}` and
- `export LD_LIBRARY_PATH=/usr/local/cuda-11.8/bin`
- Add these to your '~/.bashrc' if you want this to be permanent and not something you have to set each time you open a new terminal.

-- When you have made the changes, open a new terminal/command prompt and `nvcc --version`. It should report back `Cuda compilation tools, release 11.8.` at which point, you are good to go. -- If it doesnt report that, check you have correctly set the search environment paths, dont have overlapping other versions of cuda paths etc. +- For both Windows and Linux, you need to ensure that `nvcc` and the 11.8 cuda library files are in your environments search path. You can undo the changes below after finetuning if you prefer: + - **Windows**: Edit the Windows `Path` environment variable and add `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin` + - **Linux**: The path may be different depending on what flavour of Linux you are running, so you may need to seek out specific instructions on the internet. Generic paths **may** be: + - `export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}` and + - `export LD_LIBRARY_PATH=/usr/local/cuda-11.8/bin` + - Add these to your '~/.bashrc' if you want this to be permanent and not something you have to set each time you open a new terminal. +- When you have made the changes, open a **new** terminal/command prompt (in order to load the new search paths) and `nvcc --version`. It should report back `Cuda compilation tools, release 11.8.` at which point, you are good to go. +- If it doesn't report that, check you have correctly set the search environment paths, dont have overlapping other versions of cuda paths etc. #### ⚫ Starting Finetuning **NOTE:** Please make sure you have started AllTalk at least once after updating, so that it downloads the additional files needed for finetuning. From 8b0ade5b9f26029d6180a8cb5eb0f354fa3d7d05 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 18:34:49 +0000 Subject: [PATCH 33/39] compact routine - separate to finetune a mini compact routine for anyone who wants to compact their existing model. This is built into the new version of finetune anyway, but is here just to capture those outlier instances. --- finetune/put-voice-samples-in-here/compact.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 finetune/put-voice-samples-in-here/compact.py diff --git a/finetune/put-voice-samples-in-here/compact.py b/finetune/put-voice-samples-in-here/compact.py new file mode 100644 index 0000000..71c7ac3 --- /dev/null +++ b/finetune/put-voice-samples-in-here/compact.py @@ -0,0 +1,26 @@ +import torch +import os +MODEL_PATH = "best_model.pth" +# Check if best_model.pth exists +if not os.path.exists(MODEL_PATH): + print(f"\nCannot find \033[94m{MODEL_PATH}\033[0m in the current folder.") + + # Check if model.pth exists as an alternative + ALTERNATIVE_PATH = "model.pth" + if os.path.exists(ALTERNATIVE_PATH): + print(f"\nIf your model is currently called \033[93m{ALTERNATIVE_PATH}\033[0m please rename it to \033[94mbest_model.pth\033[0m.") + else: + print(f"Please put \033[91mbest_model.pth\033[0m in the current folder or rename your model file to \033[94mbest_model.pth\033[0m.") + exit(1) +# Attempt to load the model +try: + checkpoint = torch.load(MODEL_PATH, map_location=torch.device("cpu")) +except Exception as e: + print("Error loading checkpoint:", e) + raise +del checkpoint["optimizer"] +for key in list(checkpoint["model"].keys()): + if "dvae" in key: + del checkpoint["model"][key] +torch.save(checkpoint, "model.pth") +print(f"\nYour compacted model is created \033[93mmodel.pth\033[0m.") From 8d80151889dc8678f0bb9f5189a38228210279b4 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 18:36:51 +0000 Subject: [PATCH 34/39] New version of Finetune Simplified the final stages of finetuning. Added model compaction. Added cleaning routines to tidy up after training. --- finetune.py | 144 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 9 deletions(-) diff --git a/finetune.py b/finetune.py index 9eb3e10..f156a6f 100644 --- a/finetune.py +++ b/finetune.py @@ -14,6 +14,7 @@ import gc import time import shutil import pandas +import glob import json from pathlib import Path from tqdm import tqdm @@ -40,6 +41,7 @@ if modeldownload_config_file_path.exists(): # Extract settings from the loaded JSON base_path = Path(settings.get("base_path", "")) model_path = Path(settings.get("model_path", "")) + base_model_path = Path(settings.get("model_path", "")) files_to_download = settings.get("files_to_download", {}) else: # Default settings if the JSON file doesn't exist or is empty @@ -495,7 +497,114 @@ xtts_config_files = find_jsons(main_directory, "config.json") # XTTS vocab files (vocab.json) xtts_vocab_files = find_jsons(main_directory, "vocab.json") +########################## +#### STEP 4 AND OTHER #### +########################## +def find_latest_best_model(folder_path): + search_path = folder_path / "XTTS_FT-*" / "best_model.pth" + files = glob.glob(str(search_path), recursive=True) + latest_file = max(files, key=os.path.getctime, default=None) + return latest_file + +def compact_model(): + this_dir = Path(__file__).parent.resolve() + + best_model_path_str = find_latest_best_model(this_dir / "finetune" / "tmp-trn" / "training") + + # Check if the best model file exists + if best_model_path_str is None: + print("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) + + # Attempt to load the model + try: + checkpoint = torch.load(best_model_path, map_location=torch.device("cpu")) + except Exception as e: + print("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) + + # 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"] + + 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/trainedmodel/'") + return "Model copied to '/models/trainedmodel/'" + + +def delete_training_data(): + # Define the folder to be deleted + folder_to_delete = Path(this_dir / "finetune" / "tmp-trn") + + # Check if the folder exists before deleting + if folder_to_delete.exists(): + # Delete the folder and its contents + shutil.rmtree(folder_to_delete) + print(f"[FINETUNE] Folder {folder_to_delete} and its contents deleted successfully.") + return "Folder '/finetune/tmp-trn/' and its contents deleted successfully." + else: + print(f"[FINETUNE] Folder {folder_to_delete} does not exist.") + return "Folder '/finetune/tmp-trn/' does not exist." + +def delete_voice_sample_contents(): + # Define the folder to be cleared + folder_to_clear = Path(this_dir / "finetune" / "put-voice-samples-in-here") + + # Check if the folder exists before clearing its contents + if folder_to_clear.exists() and folder_to_clear.is_dir(): + # List all files and subdirectories in the folder + for item in os.listdir(folder_to_clear): + item_path = folder_to_clear / item + if item_path.is_file(): + # If it's a file, remove it + os.remove(item_path) + elif item_path.is_dir(): + # If it's a subdirectory, remove it recursively + shutil.rmtree(item_path) + + print(f"[FINETUNE] Contents of {folder_to_clear} deleted successfully.") + return f"Contents of 'put-voice-samples-in-here deleted' successfully." + else: + print(f"[FINETUNE] Folder {folder_to_clear} does not exist.") + return f"Folder 'put-voice-samples-in-here' does not exist." + + +####################### +#### OTHER Generic #### +####################### # define a logger to redirect class Logger: def __init__(self, filename="finetune.log"): @@ -744,6 +853,7 @@ if __name__ == "__main__": print("[FINETUNE] Dataset Generated. Move to Step 2") return "Dataset Generated. Move to Step 2", train_meta, eval_meta + ####################### #### GRADIO STEP 2 #### ####################### @@ -941,22 +1051,25 @@ if __name__ == "__main__": f""" ## What to do next
### 🟦 What you need to do - ####      🟦 The wav(s) you liked from Speaker Reference Audios are in /finetune/tmp-trn/wavs/ so copy the one(s) you selected to your /alltalk_tts/voices/ samples folder. - ####      🟦 You can delete your original samples from inside of the /finetune/put-voice-samples-in-here/ folder. - ####      🟦 In the folder /finetune/tmp-trn/training/XTTS_FT(date here)/ you will find your best_model.pth, config.json and vocab.json (also the last epoch training best_model_xxx.pth) - ####      🟦 You can delete the last epoch training model file best_model_xxx.pth (the one with the numbers). - ####      🟦 You will need to rename best_model.pth to model.pth. - ####      🟦 You will close the Finetuning application and copy your 3 files listed above over the top of the existing model files inside your /alltalk_tts/models/xttsv2_2.0.2/ folder. - ####      🟦 Start up Alltalk and you should be off and running. Preferably use the XTTS Local method for best results. + ####      🟦 There are 3x buttons below: + ####          πŸ”Ή Compact & move model. This will compress the trained model and move it, along with any large enough wav files created to /models/trainedmodel/. You can use the wav files as sample voices.. + ####          πŸ”Ή Delete Generated Training data. This will delete the finetuned model and any other training data generated during this process. You will more than likely want to do this after you have Compacted & moved the model. + ####          πŸ”Ή Delete original voice samples. This will delete the voice samples you placed in put-voice-samples-in-here (if you no longer have a use for them). + ####      🟦 I will at some point add an option within AllTalk to load a finetuned model as a seperate model. However, for now, you will have to copy it over the model in the /models/xttsv2_2.0.2/ model, if you wish to use it. + ####      🟦 If you wish to further train this model, you will also need to copy it over the model in the /models/xttsv2_2.0.2/ model folder.. ### 🟨 Clearing up disk space - ####      🟨 When you are happy with everything, you can delete the /alltalk_tts/finetune/tmp-trn/ folder. This will delete all training data that was generated. ####      🟨 If you are not going to train anything again, you can delete the whisper model from inside of your huggingface cache (3GB approx) ####          Linux ~/.cache/huggingface/hub/(folder-here) ####          Windows C:\users(your-username)\.cache\huggingface\hub\(folder-here). ####      🟨 You can also uninstall the Nvidia CUDA 11.8 Toolkit if you wish and remove your environment variable entries. """ ) - + final_progress_data = gr.Label( + label="Progress:" + ) + compact_btn = gr.Button(value="Compact and move model to '/models/trainedmodel/' (THIS WILL OVER-WRITE ANY MODEL IN THAT LOCATION)") + delete_training_btn = gr.Button(value="Delete generated training data") + delete_voicesamples_btn = gr.Button(value="Delete original voice samples") prompt_compute_btn.click( fn=preprocess_dataset, @@ -1007,6 +1120,19 @@ if __name__ == "__main__": ], outputs=[progress_gen, tts_output_audio, reference_audio], ) + + compact_btn.click( + fn=compact_model, + outputs=[final_progress_data], + ) + delete_training_btn.click( + fn=delete_training_data, + outputs=[final_progress_data], + ) + delete_voicesamples_btn.click( + fn=delete_voice_sample_contents, + outputs=[final_progress_data], + ) demo.queue().launch( show_api=False, From acc457436ae608ad7652307174c1cc88e3527d38 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 18:39:01 +0000 Subject: [PATCH 35/39] updated narrator splitting function Improved over what was before. Still more work to do in future though. --- script.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/script.py b/script.py index 0873aa7..b94e216 100644 --- a/script.py +++ b/script.py @@ -483,6 +483,9 @@ def voice_preview(string): return f"[{params['branding']}Server] Audio generation failed. Status: {generate_response.get('status')}" +def replace_asterisk(match): + return match.group(0) + '"<*' + ################################# #### TTS STANDARD GENERATION #### ################################# @@ -491,6 +494,7 @@ def output_modifier(string, state): if not params["activate"]: return string original_string = string + print("ORGINAL STRING: ", original_string) cleaned_string = before_audio_generation(string, params) if cleaned_string is None: return @@ -508,25 +512,28 @@ def output_modifier(string, state): .replace("***", "*") .replace("**", "*") .replace("\n\n", "\n") + .replace("\n", "") ) - # Clean up two asterisks (narrators) being made between a newline, making it one sentence. processed_string = re.sub(r'\.\*\n\*', '. ', processed_string) - # Clean up a few other bits. - processed_string = ( - processed_string - .replace("'", "'") - .replace("\n", " ") - # Add special characters to the quote so that we can use it to identify things later after its been split - .replace('"', '"<') - # Capture new conversations which wont have things like "e in them - .replace('"', '"<') - ) - #capturing another outlier in inital character paragraph - #print("processed string 1 is:", processed_string) + processed_string = (processed_string .replace('"\n\n*', '"<*')) + processed_string = (processed_string .replace('"\n', '< ')) + processed_string = (processed_string .replace("'", "'")) + processed_string = (processed_string .replace("\n", " ")) + processed_string = (processed_string .replace('"', '"<')) + processed_string = (processed_string .replace('"', '"<')) + #pattern = re.compile(r'(?<=[a-zA-Z!])"<(?=[a-zA-Z])') + pattern = re.compile(r'(?<=[a-zA-Z!?\.])"<(?=[a-zA-Z])') + processed_string = pattern.sub('" ', processed_string) + pattern = re.compile(r'(?<=[a-zA-Z])\*(?=[a-zA-Z])') + processed_string = pattern.sub('*"', processed_string) processed_string = processed_string.replace('"<. *', '"< *"') processed_string = processed_string.replace('< *"', '< *') processed_string = processed_string.replace('. *', '< *') - #print("processed string 2 is:", processed_string) + processed_string = processed_string.replace('! *', '"< *') + processed_string = processed_string.replace('? *', '< *') + processed_string = processed_string.replace('* ', '* "<') + processed_string = processed_string.replace('*. ', '* "<') + processed_string = re.sub(r'\*(?=[a-zA-Z])', replace_asterisk, processed_string) # Set up a tracking of the individual wav files. audio_files_all_paragraphs = [] # Split the line using " and ".* " (so end of sentences, leaving special characters added to the start of all OTHER sentences, bar possibly the first one if its starting with a * @@ -534,7 +541,7 @@ def output_modifier(string, state): audio_files_paragraph = [] for i, part in enumerate(parts): # Skip parts that are too short - if len(part.strip()) <= 1: + if len(part.strip()) <= 3: continue # Figure out which type of line it is, then replace characters as necessary to avoid TTS trying to pronunce them, htmlunescape after. # Character will always be a < with a letter immediately after it From 53a2d0a65e3dcb77380451cc5955ec09f30d41d0 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 19:25:59 +0000 Subject: [PATCH 36/39] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d4407cc..3e728f2 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,9 @@ AllTalk is an updated version of the Coqui_tts extension for Text Generation web - πŸ”΄ [Future to-do list & Upcoming updates](https://github.com/erew123/alltalk_tts?#-future-to-do-list) #### Updates -Dec 25th - Applied a small update to avoid a possible race condition on file naming with small sentences when generating narrator/character speech. Please update if you are experiencing missing small bits of missing audio on narrator/character. +**Dec 28th**- Finetuning has been updated to compact models and make the final steps easier (buttons basically). Narrator has been updated. If you wish to compact existing finetuned models, pre the update please see [here](https://github.com/erew123/alltalk_tts/issues/28) + +**Dec 25th** - Applied a small update to avoid a possible race condition on file naming with small sentences when generating narrator/character speech. Please update if you are experiencing missing small bits of missing audio on narrator/character. ####     πŸ”„ **Minor updates/bug fixes list** can be found [here](https://github.com/erew123/alltalk_tts/issues/25) From cd47f6b12376ebe673268d5e38ead7897ad6cd8a Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:38:12 +0000 Subject: [PATCH 37/39] Add files via upload --- finetune/compact.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 finetune/compact.py diff --git a/finetune/compact.py b/finetune/compact.py new file mode 100644 index 0000000..71c7ac3 --- /dev/null +++ b/finetune/compact.py @@ -0,0 +1,26 @@ +import torch +import os +MODEL_PATH = "best_model.pth" +# Check if best_model.pth exists +if not os.path.exists(MODEL_PATH): + print(f"\nCannot find \033[94m{MODEL_PATH}\033[0m in the current folder.") + + # Check if model.pth exists as an alternative + ALTERNATIVE_PATH = "model.pth" + if os.path.exists(ALTERNATIVE_PATH): + print(f"\nIf your model is currently called \033[93m{ALTERNATIVE_PATH}\033[0m please rename it to \033[94mbest_model.pth\033[0m.") + else: + print(f"Please put \033[91mbest_model.pth\033[0m in the current folder or rename your model file to \033[94mbest_model.pth\033[0m.") + exit(1) +# Attempt to load the model +try: + checkpoint = torch.load(MODEL_PATH, map_location=torch.device("cpu")) +except Exception as e: + print("Error loading checkpoint:", e) + raise +del checkpoint["optimizer"] +for key in list(checkpoint["model"].keys()): + if "dvae" in key: + del checkpoint["model"][key] +torch.save(checkpoint, "model.pth") +print(f"\nYour compacted model is created \033[93mmodel.pth\033[0m.") From d20ee95e678e4ae99bd6676fb1e68c7495a5a525 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:38:33 +0000 Subject: [PATCH 38/39] Delete finetune/put-voice-samples-in-here/compact.py --- finetune/put-voice-samples-in-here/compact.py | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 finetune/put-voice-samples-in-here/compact.py diff --git a/finetune/put-voice-samples-in-here/compact.py b/finetune/put-voice-samples-in-here/compact.py deleted file mode 100644 index 71c7ac3..0000000 --- a/finetune/put-voice-samples-in-here/compact.py +++ /dev/null @@ -1,26 +0,0 @@ -import torch -import os -MODEL_PATH = "best_model.pth" -# Check if best_model.pth exists -if not os.path.exists(MODEL_PATH): - print(f"\nCannot find \033[94m{MODEL_PATH}\033[0m in the current folder.") - - # Check if model.pth exists as an alternative - ALTERNATIVE_PATH = "model.pth" - if os.path.exists(ALTERNATIVE_PATH): - print(f"\nIf your model is currently called \033[93m{ALTERNATIVE_PATH}\033[0m please rename it to \033[94mbest_model.pth\033[0m.") - else: - print(f"Please put \033[91mbest_model.pth\033[0m in the current folder or rename your model file to \033[94mbest_model.pth\033[0m.") - exit(1) -# Attempt to load the model -try: - checkpoint = torch.load(MODEL_PATH, map_location=torch.device("cpu")) -except Exception as e: - print("Error loading checkpoint:", e) - raise -del checkpoint["optimizer"] -for key in list(checkpoint["model"].keys()): - if "dvae" in key: - del checkpoint["model"][key] -torch.save(checkpoint, "model.pth") -print(f"\nYour compacted model is created \033[93mmodel.pth\033[0m.") From 3cd22081f4e741b901bde7931ab68416918f3c09 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 28 Dec 2023 21:05:59 +0000 Subject: [PATCH 39/39] Update script.py --- script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.py b/script.py index b94e216..30eb714 100644 --- a/script.py +++ b/script.py @@ -494,7 +494,7 @@ def output_modifier(string, state): if not params["activate"]: return string original_string = string - print("ORGINAL STRING: ", original_string) + #print("ORGINAL STRING: ", original_string) cleaned_string = before_audio_generation(string, params) if cleaned_string is None: return