21 KiB
21 KiB
In [8]:
#@markdown Mounting your Google Drive allows you to drag and drop samples/models via the `drive/Mydrive` path. This allows you<br>
#@markdown to store or use specific audio samples or finetuned models.<br><br>
#@markdown **Audio samples** need to be placed in `alltalk_tts/voices`<br>
#@markdown **XTTS models** need to be placed in `alltalk_tts/models/xtts/{yourmodelfolderhere}`<br>
mount_gdrive = False #@param{type:"boolean"}
if mount_gdrive:
from google.colab import drive
drive.mount('/content/drive')
from IPython.display import clear_output
print("*******************************************************************")
print("** Installing server requirements. This will take 5-10 minutes ****")
print("*******************************************************************")
!apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 libaio-dev espeak-ng > '/dev/null' 2>&1
clear_output()
print("************************")
print("*** Cloning AllTalk ****")
print("************************\n")
!git clone -b alltalkbeta https://github.com/erew123/alltalk_tts
clear_output()
print("\n********************************")
print("*** Installing Requirements ****")
print("********************************\n")
!python -m pip install --upgrade "pip<24.1"
!pip install --quiet -r /content/alltalk_tts/system/requirements/requirements_colab.txt
clear_output()
print("\n*****************************")
print("*** Installing DeepSpeed ****")
print("*****************************\n")
!pip install deepspeed
!pip install orjson
!pip install faiss-cpu
!pip install fairseq
clear_output()
print("\n******************************")
print("*** Installing Cloudflare ****")
print("******************************\n")
# Install cloudflare
!wget -q https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb > '/dev/null' 2>&1
!apt install ./cloudflared-linux-amd64.deb aria2 > '/dev/null' 2>&1
!rm cloudflared-linux-amd64.deb > '/dev/null' 2>&1
!python -m spacy download en_core_web_md
clear_output()
print("\n***************************")
print("*** Installing Cutlass ****")
print("***************************\n")
# Clone the CUTLASS repository
!git clone https://github.com/NVIDIA/cutlass.git
!export CUTLASSPATH=/content/cutlass
!sudo curl -L https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz -o /usr/local/bin/ffmpeg.tar.xz
clear_output()
%cd /usr/local/bin/
clear_output()
!7z e /usr/local/bin/ffmpeg.tar.xz -y
clear_output()
!7z e /usr/local/bin/ffmpeg.tar -y
clear_output()
!sudo chmod a+rx /usr/local/bin/ffmpeg
clear_output()
!pip uninstall jax -y
clear_output()
print("************************************")
print("** Server requirements installed ***")
print("*** Please proceed to next step ****")
print("************************************\n")************************************ ** Server requirements installed *** *** Please proceed to next step **** ************************************
In [4]:
#@markdown Links to the API and Gradio interface will be shown when AllTalk has loaded in.<br>
#@markdown The API address is what you would use in SillyTavern.<br>
#@markdown Do not start this if you want to run Finetuning.
import re
import time
import json
import threading
import time
def keep_alive():
while True:
time.sleep(60) # Run every 60 seconds (adjust as needed)
keep_alive_thread = threading.Thread(target=keep_alive)
keep_alive_thread.start()
Tunnel = "cloudflare"
host = "127.0.0.1"
ports = [7851, 7852]
tunnel_urls = []
# Starting tunnels for each port.
for port in ports:
if Tunnel == "cloudflare":
!nohup cloudflared tunnel --url http://{host}:{port} > lt_{port}.log 2>&1 &
else:
!nohup npx lt -p {port} > lt_{port}.log 2>&1 &
# Wait a couple of seconds for the tunnels to initialize.
time.sleep(10)
# Extract URLs for each tunnel.
for port in ports:
log_file = f'lt_{port}.log'
with open(log_file, 'r') as testwritefile:
log_content = testwritefile.read()
# Use regular expressions to find the URL.
if Tunnel == "cloudflare":
url_match = re.search(r'(https://[-a-z0-9]+\.trycloudflare\.com)', log_content)
else:
url_match = re.search(r'your url is: (https?://\S+)', log_content)
if url_match:
tunnel_url = url_match.group(1)
tunnel_urls.append(tunnel_url)
else:
print(f"URL for port {port} not found.")
# Save the tunnel URLs to a JSON file.
try:
# Try to open the JSON file for reading.
with open('/content/alltalk_tts/googlecolab.json', 'r') as f:
data = json.load(f)
except FileNotFoundError:
# If the file doesn't exist, create an empty dictionary.
data = {}
data['google_ip_address'] = tunnel_urls
# Write the modified data (or newly created data) back to the file.
with open('/content/alltalk_tts/googlecolab.json', 'w') as f:
json.dump(data, f)
host = "0.0.0.0"
if Tunnel == "localtunnel":
print("Before you copy the link above click on it and copy that ip:")
!curl ipv4.icanhazip.com
# Start API server.
!python /content/alltalk_tts/script.py
[AllTalk TTS][94m _ _ _ [1;35m_____ _ _ [0m _____ _____ ____ [AllTalk TTS][94m / \ | | |[1;35m_ _|_ _| | | __ [0m |_ _|_ _/ ___| [AllTalk TTS][94m / _ \ | | |[1;35m | |/ _` | | |/ / [0m | | | | \___ \ [AllTalk TTS][94m / ___ \| | |[1;35m | | (_| | | < [0m | | | | ___) | [AllTalk TTS][94m /_/ \_\_|_|[1;35m |_|\__,_|_|_|\_\ [0m |_| |_| |____/ [AllTalk TTS] [AllTalk TTS] [92mConfig file update: [93mNo Updates required[0m [AllTalk TTS] [92mStart-up Mode : [93mStandalone mode[0m [AllTalk TTS] [AllTalk TTS] [92mThis is the first time startup. Please download a start TTS model.[0m [AllTalk TTS] [AllTalk TTS] [94mAvailable First Time Start-up models:[0m [AllTalk TTS] [AllTalk TTS] [93m1. [94mpiper - piper[0m [AllTalk TTS] [93m2. [94mvits - tts_models--en--vctk--vits[0m [AllTalk TTS] [93m3. [94mxtts - xttsv2_2.0.3[0m [AllTalk TTS] [93m4.[94m I have my own models already[0m [AllTalk TTS] [AllTalk TTS] [94mIn [91m60 seconds[0m [94ma Piper model will be [91mdownloaded automatically.[0m [AllTalk TTS] [AllTalk TTS] [92mEnter your choice 1-4: [0m [AllTalk TTS] [AllTalk TTS] No input received. Proceeding with the default model (piper). /content/alltalk_tts/models/piper/en_US-ljspeech-high.onnx: 100% 114M/114M [00:01<00:00, 80.8MiB/s] /content/alltalk_tts/models/piper/en_US-ljspeech-high.onnx.json: 100% 4.97k/4.97k [00:00<00:00, 14.9MiB/s] [AllTalk TTS] piper model downloaded and configuration updated successfully. [AllTalk TTS] [AllTalk TTS] [93mIf you have you have UPGRADED from v1 ensure you have re-installed[0m [AllTalk TTS] [93mthe requirements. Otherwise you will get failures and errors![0m [AllTalk TTS] [93mOn Linux ignore the [0m'sparse_attn requires a torch version' [93mand[0m [AllTalk TTS] [0m'using untested triton version' [93mmessages.[0m [AllTalk TTS] [AllTalk TTS] [92mWAV file deletion :[93m Disabled[0m [AllTalk TTS] [92mGithub updated :[93m 1st July 2024 at 08:57[0m [AllTalk TTS] [AllTalk TTS] [94mGoogle Colab Detected[00m [AllTalk TTS] [AllTalk ENG] [92mTranscoding :[93m ffmpeg found[0m [93m [WARNING] [0m Please specify the CUTLASS repo directory as environment variable $CUTLASS_PATH [93m [WARNING] [0m NVIDIA Inference is only supported on Ampere and newer architectures [93m [WARNING] [0m sparse_attn requires a torch version >= 1.5 and < 2.0 but detected 2.3 [93m [WARNING] [0m using untested triton version (2.3.1), only 1.0.0 is known to be compatible [AllTalk ENG] [92mDeepSpeed version :[93m 0.14.4 [0m [AllTalk ENG] [92mPython Version :[93m 3.10.12[0m [AllTalk ENG] [92mPyTorch Version :[93m 2.3.1+cu121[0m [AllTalk ENG] [92mCUDA Version :[93m 12.1[0m [AllTalk ENG] [AllTalk ENG][94m Model/Engine :[93m Piper[94m Ready[0m [AllTalk ENG] [94mLoad time :[93m 0.00 seconds.[0m [AllTalk TTS] [AllTalk TTS] [94mAPI Address :[00m [92mhttps://refresh-jackson-firefox-elementary.trycloudflare.com[00m [AllTalk TTS] [94mGradio Light:[00m [92mhttps://lawsuit-effectively-assessing-z.trycloudflare.com[00m [AllTalk TTS] [94mGradio Dark :[00m [92mhttps://lawsuit-effectively-assessing-z.trycloudflare.com?__theme=dark[00m [AllTalk TTS] themes/theme_schema@0.0.1.json: 100% 13.1k/13.1k [00:00<00:00, 45.7MB/s] [AllTalk TTS] Please use [91mCtrl+C[0m when exiting AllTalk otherwise a [AllTalk TTS] subprocess may continue running in the background. [AllTalk TTS] [AllTalk TTS] AllTalk Server Ready Downloading LICENSE.txt... 100% 4.01k/4.01k [00:00<00:00, 11.6MiB/s] Downloading README.md... 100% 4.26k/4.26k [00:00<00:00, 13.0MiB/s] Downloading config.json... 100% 4.37k/4.37k [00:00<00:00, 12.1MiB/s] Downloading model.pth... 100% 1.87G/1.87G [00:30<00:00, 61.2MiB/s] Downloading dvae.pth... 100% 211M/211M [00:04<00:00, 50.7MiB/s] Downloading mel_stats.pth... 100% 1.07k/1.07k [00:00<00:00, 2.90MiB/s] Downloading speakers_xtts.pth... 100% 7.75M/7.75M [00:00<00:00, 77.9MiB/s] Downloading vocab.json... 100% 361k/361k [00:00<00:00, 26.4MiB/s] [AllTalk Shutdown] [94mReceived Ctrl+C, terminating subprocess. Kill your Python processes if this fails to exit.[92m [AllTalk Shutdown] [94mReceived Ctrl+C, terminating subprocess. Kill your Python processes if this fails to exit.[92m ^C
In [7]:
#@markdown Starts the Finetuning application for XTTS models.<br><br>
#@markdown You can either run the `Start AllTalk` to download the base XTTS model(s) for finetuning. Or you can use the folder icon on the left hand<br>
#@markdown side of the screen and upload an XTTS model that you want to finetune. If you are manually uploading a model, you would place your model<br>
#@markdown files in `models/xtts/{yourmodelfolderhere}` and you will need all the models files in that folder `config.json, dvae.pth, mel_stats.pth,`<br>
#@markdown `model.pth, speakers_xtts.pth, vocab.json`. Without 1x model available, Finetuning will not start.<br><br>
#@markdown Likewise you can download your finetuned model from there, OR copy it to your Google Drive after finetuning, for later use in AllTalk.<br><br>
#@markdown To access the Finetuning Gradio interface, connect to the `Google Colab Finetuning url` when Finetuning has started.<br>
import re
import time
import json
import threading
import time
def keep_alive():
while True:
time.sleep(60) # Run every 60 seconds (adjust as needed)
keep_alive_thread = threading.Thread(target=keep_alive)
keep_alive_thread.start()
Tunnel = "cloudflare"
host = "127.0.0.1"
ports = [7052]
tunnel_urls = []
# Starting tunnels for each port.
for port in ports:
if Tunnel == "cloudflare":
!nohup cloudflared tunnel --url http://{host}:{port} > lt_{port}.log 2>&1 &
else:
!nohup npx lt -p {port} > lt_{port}.log 2>&1 &
# Wait a couple of seconds for the tunnels to initialize.
time.sleep(10)
# Extract URLs for each tunnel.
for port in ports:
log_file = f'lt_{port}.log'
with open(log_file, 'r') as testwritefile:
log_content = testwritefile.read()
# Use regular expressions to find the URL.
if Tunnel == "cloudflare":
url_match = re.search(r'(https://[-a-z0-9]+\.trycloudflare\.com)', log_content)
else:
url_match = re.search(r'your url is: (https?://\S+)', log_content)
if url_match:
tunnel_url = url_match.group(1)
tunnel_urls.append(tunnel_url)
print(f"Google Colab Finetuning url: {tunnel_url}\n")
print(f"********************************************************************")
print(f"**** Use the above URL to connect to Finetuning on Google Colab ****")
print(f"********************************************************************")
print(f"************* Now starting the Finetuning Application **************")
print(f"********************************************************************\n")
else:
print(f"URL for port {port} not found.")
# Save the tunnel URLs to a JSON file.
try:
# Try to open the JSON file for reading.
with open('/content/alltalk_tts/googlecolab.json', 'r') as f:
data = json.load(f)
except FileNotFoundError:
# If the file doesn't exist, create an empty dictionary.
data = {}
data['google_ip_address'] = tunnel_urls
# Write the modified data (or newly created data) back to the file.
with open('/content/alltalk_tts/googlecolab.json', 'w') as f:
json.dump(data, f)
host = "0.0.0.0"
if Tunnel == "localtunnel":
print("Before you copy the link above click on it and copy that ip:")
!curl ipv4.icanhazip.com
# Start API server.
!python /content/alltalk_tts/finetune.py
Google Colab Finetuning url: https://assistance-amazing-periods-payday.trycloudflare.com ******************************************************************** **** Use the above URL to connect to Finetuning on Google Colab **** ******************************************************************** [FINETUNE] HTTP Request: GET https://checkip.amazonaws.com/ "HTTP/1.1 200 " [FINETUNE] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK" Running on local URL: http://127.0.0.1:7052 [FINETUNE] HTTP Request: GET http://127.0.0.1:7052/startup-events "HTTP/1.1 200 OK" [FINETUNE] HTTP Request: HEAD http://127.0.0.1:7052/ "HTTP/1.1 200 OK" To create a public link, set `share=True` in `launch()`. [FINETUNE] Received interrupt signal. Cleaning up and exiting... [0m