{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"colab":{"provenance":[],"gpuType":"T4"},"accelerator":"GPU","kaggle":{"accelerator":"gpu","dataSources":[],"dockerImageVersionId":30919,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## Welcome to the *xtts*-finetune-webui gradio gui!\n\nThis webui is a slightly modified copy of the official webui for finetune xtts.\n\nIf you are looking for an option for normal XTTS use look here https://github.com/daswer123/xtts-webui","metadata":{"id":"OVjEG_yGoC2W"}},{"cell_type":"markdown","source":"## Disclamer this version should be considered alpha/beta!\n\n### Potential issues\n- float16 is disabled and float32 is used (not sure how to get float16 to work with kaggle)\n- this doesn't use kaggles persistant output directory as its limited to 20gb make sure to download models before ending sessions\n- the main disk is limited to 57 gb (you can go over it, it wont immediatly stop, but kaggle can crash at anytime)","metadata":{}},{"cell_type":"code","source":"# @title 🛠️ Install requirments\n#!DEBIAN_FRONTEND=noninteractive\n!sudo apt-get update # && sudo apt-get -y upgrade\n!sudo apt-get -y install libegl1\n!sudo apt-get -y install libopengl0\n!sudo apt-get -y install libxcb-cursor0\n!pip install -r https://raw.githubusercontent.com/daswer123/xtts-finetune-webui/main/requirements.txt\n!pip install gradio==4.44.1\n!pip install fastapi==0.103.1\n!pip install pydantic==2.3.0","metadata":{"cellView":"form","id":"44HpAIVRfJve","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!nvcc --version\n!apt-get install libcudnn9-cuda-12 9.1.0 #fix a dependency issue","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"The code is basically the same as:\n\nhttps://github.com/daswer123/xtts-webui\n\nOnly change to repo is that float16 is changed to float32:\n\nhttps://github.com/Rihcus/xtts-finetune-webui/blob/2345589fb773a32b6f48b8f1aa7f4eca1aab476b/xtts_demo.py#L309","metadata":{}},{"cell_type":"code","source":"# @title 🚀 Run interface\n%cd /tmp/ \n!git clone https://github.com/Rihcus/xtts-finetune-webui #float16 is swapped to float32\n%cd /tmp/xtts-finetune-webui\n!python xtts_demo.py --share","metadata":{"cellView":"form","id":"62Da1Q5AgN3W","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"This part was from colab version not using it here","metadata":{}},{"cell_type":"code","source":"# import shutil\n# import requests\n# import os\n# from tqdm import tqdm # Progress bar library\n\n# # Define the paths\n# finetune_dir = '/content/xtts-finetune-webui/finetune_models/ready' # @param {type:\"string\"}\n# dataset_dir = '/content/xtts-finetune-webui/finetune_models/dataset' # @param {type:\"string\"}\n\n# # Create a temporary directory to collect both folders before zipping\n# temp_dir = \"/content/temp_finetune_dataset\"\n# os.makedirs(temp_dir, exist_ok=True)\n\n# # Copy both directories into the temporary directory with a progress bar\n# def copy_with_progress(src, dst):\n# total_files = sum(len(files) for _, _, files in os.walk(src))\n# with tqdm(total=total_files, desc=f\"Copying {os.path.basename(src)}\") as pbar:\n# for root, _, files in os.walk(src):\n# rel_path = os.path.relpath(root, src)\n# target_path = os.path.join(dst, rel_path)\n# os.makedirs(target_path, exist_ok=True)\n# for file in files:\n# shutil.copy(os.path.join(root, file), target_path)\n# pbar.update(1)\n\n# copy_with_progress(finetune_dir, os.path.join(temp_dir, \"ready\"))\n# copy_with_progress(dataset_dir, os.path.join(temp_dir, \"dataset\"))\n\n# # Create a zip file of the combined directories with progress\n# zip_filename = \"finetune_and_dataset.zip\"\n# with tqdm(total=100, desc=\"Zipping files\") as pbar:\n# shutil.make_archive(\"finetune_and_dataset\", 'zip', root_dir=temp_dir)\n# pbar.update(100)\n\n# # Define a function to stream the upload with a progress bar\n# def upload_with_progress(file_path, url):\n# file_size = os.path.getsize(file_path)\n# with open(file_path, 'rb') as f, tqdm(\n# total=file_size, unit='B', unit_scale=True, desc=\"Uploading\"\n# ) as progress:\n# response = requests.post(\n# url,\n# files={\"file\": (file_path, f)},\n# stream=True,\n# headers={\"Connection\": \"keep-alive\"},\n# )\n# # Update the progress bar as chunks are sent\n# for chunk in response.iter_content(chunk_size=4096):\n# if chunk:\n# progress.update(len(chunk))\n# return response\n\n# # Upload the zip file to file.io with a progress bar\n# response = upload_with_progress(zip_filename, \"https://file.io/?expires=1d\")\n\n# # Parse the response and display the download link\n# if response.status_code == 200:\n# download_link = response.json().get('link', 'Error: No link found.')\n# print(f\"Your file is ready: {download_link}\")\n# else:\n# print(f\"Failed to upload: {response.status_code} - {response.text}\")\n","metadata":{"cellView":"form","id":"MYBWgKevr6S3","trusted":true},"outputs":[],"execution_count":null}]}