ai-voice-cloning/notebook_colab.ipynb
2023-10-27 18:11:49 +00:00

222 lines
6.2 KiB
Plaintext
Executable File

{
"nbformat":4,
"nbformat_minor":0,
"metadata":{
"colab":{
"private_outputs":true,
"provenance":[
]
},
"kernelspec":{
"name":"python3",
"display_name":"Python 3"
},
"language_info":{
"name":"python"
},
"accelerator":"GPU",
"gpuClass":"standard"
},
"cells":[
{
"cell_type":"markdown",
"source":[
"## Initialization"
],
"metadata":{
"id":"ni41hmE03DL6"
}
},
{
"cell_type":"code",
"execution_count":null,
"metadata":{
"id":"FtsMKKfH18iM"
},
"outputs":[
],
"source":[
"!apt install python3.10-venv\n",
"!git clone https://git.ecker.tech/mrq/ai-voice-cloning/\n",
"%cd /content/ai-voice-cloning\n",
"# get local dependencies\n",
"!git submodule init\n",
"!git submodule update --remote\n",
"# setup venv\n",
"!python3 -m venv venv\n",
"!source ./venv/bin/activate\n",
"!python3 -m pip install --upgrade pip # just to be safe\n",
"# CUDA\n",
"!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n",
"# install requirements\n",
"!python3 -m pip install -r ./modules/tortoise-tts/requirements.txt # install TorToiSe requirements\n",
"!python3 -m pip install -e ./modules/tortoise-tts/ # install TorToiSe\n",
"!python3 -m pip install -r ./modules/dlas/requirements.txt # instal DLAS requirements, last, because whisperx will break a dependency here\n",
"!python3 -m pip install -e ./modules/dlas/ # install DLAS\n",
"!python3 -m pip install -r ./requirements.txt # install local requirements"
]
},
{
"cell_type":"markdown",
"source":[
"# Update Repos"
],
"metadata":{
"id":"IzrGt5IcHlAD"
}
},
{
"cell_type":"code",
"source":[
"# for my debugging purposes\n",
"%cd /content/ai-voice-cloning/\n",
"!./update.sh"
],
"metadata":{
"id":"3DktoOXSHmtw"
},
"execution_count":null,
"outputs":[
]
},
{
"cell_type":"markdown",
"source":[
"# Mount Drive"
],
"metadata":{
"id":"2Y4t9zDIZMTg"
}
},
{
"cell_type":"code",
"source":[
"# only run once, this will save all userdata to your Drive\n",
"# it shouldn't delete through symlinks, but you never know\n",
"\n",
"from google.colab import drive\n",
"\n",
"%cd /content/ai-voice-cloning\n",
"drive.flush_and_unmount()\n",
"!rm -r ./{training,results,voices,config}\n",
"drive.mount('/content/drive')\n",
"!mkdir /content/drive/MyDrive/ai-voice-cloning/\n",
"!mv /content/drive/MyDrive/{training,results,voices,config} /content/drive/MyDrive/ai-voice-cloning\n",
"!mkdir /content/drive/MyDrive/ai-voice-cloning/{training,results,voices,config}\n",
"!ln -s /content/drive/MyDrive/ai-voice-cloning/{training,results,voices,config} ./"
],
"metadata":{
"id":"SGt9gyvubveT"
},
"execution_count":null,
"outputs":[
]
},
{
"cell_type":"markdown",
"source":[
"## Running"
],
"metadata":{
"id":"EM3iNqgJF6Be"
}
},
{
"cell_type":"code",
"source":[
"%cd /content/ai-voice-cloning/\n",
"!source ./venv/bin/activate\n",
"!python3 ./src/main.py --share"
],
"metadata":{
"id":"QRA8jF3cF-YJ"
},
"execution_count":null,
"outputs":[
]
},
{
"cell_type":"markdown",
"source":[
"# Restart Runtime"
],
"metadata":{
"id":"vH9KU7SMGDxb"
}
},
{
"cell_type":"code",
"source":[
"exit()"
],
"metadata":{
"id":"EWeyUPvgGDX5"
},
"execution_count":null,
"outputs":[
]
},
{
"cell_type":"markdown",
"source":[
"# Fallback Training"
],
"metadata":{
"id":"ggLY9A9KA21D"
}
},
{
"cell_type":"code",
"source":[
"# This is in case you can't get training through the web UI\n",
"%cd /content/ai-voice-cloning\n",
"!python ./dlas/codes/train.py -opt ./training/finetune.yaml"
],
"metadata":{
"id":"-KayB8klA5tY"
},
"execution_count":null,
"outputs":[
]
},
{
"cell_type":"markdown",
"source":[
"## Exporting"
],
"metadata":{
"id":"2AnVQxEJx47p"
}
},
{
"cell_type":"code",
"source":[
"# if you're not using drive mounting\n",
"%cd /content/ai-voice-cloning\n",
"!apt install -y p7zip-full\n",
"from datetime import datetime\n",
"timestamp = datetime.now().strftime('%m-%d-%Y_%H:%M:%S')\n",
"!mkdir -p \"../{timestamp}/results\"\n",
"!mv ./results/* \"../{timestamp}/results/.\"\n",
"!mv ./training/* \"../{timestamp}/training/.\"\n",
"!7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \"../{timestamp}.7z\" \"../{timestamp}/\"\n",
"!ls ~/\n",
"!echo \"Finished zipping, archive is available at {timestamp}.7z\""
],
"metadata":{
"id":"YOACiDCXx72G"
},
"execution_count":null,
"outputs":[
]
}
]
}