mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-17 00:23:14 +00:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
#FROM python:3.10-bullseye
|
||||
|
||||
# Alternatively,
|
||||
FROM nvidia/cuda:12.0.1-runtime-ubuntu22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# NB: ffmpeg for transcoding opus -> wav
|
||||
# NB(bt,2023-05-04): Installing lsof, htop, ripgrep, and other debugging tools
|
||||
# NB(bt,2023-05-04): Installing rsync to monitor time it takes for files to sync
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
ffmpeg \
|
||||
htop \
|
||||
libsndfile1 \
|
||||
lsof \
|
||||
nvidia-driver-515 \
|
||||
python3-pip \
|
||||
python3.10 \
|
||||
python3.10-dev \
|
||||
python3.10-venv \
|
||||
ripgrep \
|
||||
rsync \
|
||||
vim \
|
||||
wget \
|
||||
--no-install-recommends \
|
||||
&& apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||
|
||||
#ENV DEBIAN_FRONTEND=noninteractive
|
||||
#
|
||||
#RUN apt-get update && apt-get install -y \
|
||||
# rsync \
|
||||
# --no-install-recommends \
|
||||
# && apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||
|
||||
RUN mkdir /python_install
|
||||
RUN mkdir /model_code
|
||||
|
||||
WORKDIR /python_install
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
# NB: Kubernetes will copy over the venv we create here.
|
||||
RUN python3 -m venv python \
|
||||
&& . python/bin/activate \
|
||||
&& pip install -r requirements.txt
|
||||
&& pip install piper-tts
|
||||
|
||||
# NB: The model code is uploaded next
|
||||
WORKDIR /model_code
|
||||
|
||||
COPY . .
|
||||
@@ -0,0 +1,23 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 liujing04
|
||||
Copyright (c) 2023 源文雨
|
||||
Copyright (c) 2023 Ftps
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,45 @@
|
||||
本软件及其相关代码以MIT协议开源,作者不对软件具备任何控制力,使用软件者、传播软件导出的声音者自负全责。
|
||||
如不认可该条款,则不能使用或引用软件包内任何代码和文件。
|
||||
|
||||
特此授予任何获得本软件和相关文档文件(以下简称“软件”)副本的人免费使用、复制、修改、合并、出版、分发、再授权和/或销售本软件的权利,以及授予本软件所提供的人使用本软件的权利,但须符合以下条件:
|
||||
上述版权声明和本许可声明应包含在软件的所有副本或实质部分中。
|
||||
软件是“按原样”提供的,没有任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和不侵权的保证。在任何情况下,作者或版权持有人均不承担因软件或软件的使用或其他交易而产生、产生或与之相关的任何索赔、损害赔偿或其他责任,无论是在合同诉讼、侵权诉讼还是其他诉讼中。
|
||||
|
||||
|
||||
The LICENCEs for related libraries are as follows.
|
||||
相关引用库协议如下:
|
||||
|
||||
ContentVec
|
||||
https://github.com/auspicious3000/contentvec/blob/main/LICENSE
|
||||
MIT License
|
||||
|
||||
VITS
|
||||
https://github.com/jaywalnut310/vits/blob/main/LICENSE
|
||||
MIT License
|
||||
|
||||
HIFIGAN
|
||||
https://github.com/jik876/hifi-gan/blob/master/LICENSE
|
||||
MIT License
|
||||
|
||||
gradio
|
||||
https://github.com/gradio-app/gradio/blob/main/LICENSE
|
||||
Apache License 2.0
|
||||
|
||||
ffmpeg
|
||||
https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv3
|
||||
https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2021-02-28-12-32/ffmpeg-n4.3.2-160-gfbb9368226-win64-lgpl-4.3.zip
|
||||
LPGLv3 License
|
||||
MIT License
|
||||
|
||||
ultimatevocalremovergui
|
||||
https://github.com/Anjok07/ultimatevocalremovergui/blob/master/LICENSE
|
||||
https://github.com/yang123qwe/vocal_separation_by_uvr5
|
||||
MIT License
|
||||
|
||||
audio-slicer
|
||||
https://github.com/openvpi/audio-slicer/blob/main/LICENSE
|
||||
MIT License
|
||||
|
||||
PySimpleGUI
|
||||
https://github.com/PySimpleGUI/PySimpleGUI/blob/master/license.txt
|
||||
LPGLv3 License
|
||||
@@ -0,0 +1,92 @@
|
||||
# TTS and RVC Inference Script
|
||||
|
||||
## Overview
|
||||
|
||||
This Python script runs both Text-To-Speech (TTS) and Retrieval-based-Voice-Conversion (RVC) inferences. It uses Piper for TTS and a custom RVC voice conversion model. The script takes a variety of command-line arguments to specify the models, configurations, and audio files to use.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.x
|
||||
- PyTorch 2.0 or higher
|
||||
- Piper TTS
|
||||
- ffmpeg (for audio processing)
|
||||
|
||||
### Installation
|
||||
|
||||
1. Install Python 3.x and PyTorch 2.0 or higher.
|
||||
2. Install Piper TTS via pip:
|
||||
|
||||
```bash
|
||||
pip install piper-tts
|
||||
```
|
||||
3. **Download Piper Voice Models**
|
||||
|
||||
Piper voice models can be downloaded from [Hugging Face's Piper Voices Repository](https://huggingface.co/rhasspy/piper-voices/tree/v1.0.0/en/en_US).
|
||||
|
||||
4. Make sure `ffmpeg` is installed and available in the system's PATH.
|
||||
|
||||
- For Ubuntu:
|
||||
|
||||
```bash
|
||||
sudo apt-get install ffmpeg
|
||||
```
|
||||
|
||||
- For macOS:
|
||||
|
||||
```bash
|
||||
brew install ffmpeg
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To run the script, you need to pass in several command-line arguments.
|
||||
|
||||
### TTS Arguments
|
||||
|
||||
- `--tts_model_path`: Required. The path to the TTS model.
|
||||
- `--tts_config_path`: Required. The path to the TTS configuration file.
|
||||
- `--text`: Required. The text you want to convert to speech.
|
||||
|
||||
#### Additional TTS Options
|
||||
|
||||
- `--length_scale`: Optional. Phoneme length scale for TTS. Default is 1.0.
|
||||
- `--noise_scale`: Optional. Noise scale for TTS. Default is 0.5.
|
||||
- `--noise_w`: Optional. Phoneme width noise for TTS. Default is 0.3.
|
||||
- `--sentence_silence`: Optional. Seconds of silence after each sentence in TTS. Default is 0.0.
|
||||
|
||||
### RVC Arguments
|
||||
|
||||
- `--model_path`: Path to the VC model.
|
||||
- `--model_index_path`: (Optional) Path to the VC model index.
|
||||
- `--hubert_model_path`: (Optional) Path to the Hubert model. Default is `hubert_base.pt`.
|
||||
- `--input_audio_filename`: Path to the input audio file for VC.
|
||||
- `--output_audio_filename`: Path to save the output audio file from VC.
|
||||
|
||||
... (Other optional arguments for fine-tuning the VC process)
|
||||
|
||||
`--f0up_key`: The f0 key for the input audio file.
|
||||
|
||||
`--index_path`: Path to the index file.
|
||||
|
||||
`--f0method`: F0 estimation method to be used ('pm' 'harvest' 'crepe' or rmvpe).
|
||||
|
||||
`--index_rate`: The rate for the index. (Search feature ratio)
|
||||
|
||||
`--device`: The computation device to be used ('cuda:0' for GPU or 'cpu' for CPU).
|
||||
|
||||
`--is_half`: Boolean value indicating whether to use half precision. Use 'True' for half-precision and 'False' for full-precision.
|
||||
|
||||
`--filter_radius`: The radius of the filter. (If >=3: apply median filtering to the harvested pitch results. The value represents the filter radius and can reduce breathiness.)
|
||||
|
||||
`--resample_sr`: The sample rate for resampling. (Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling)
|
||||
|
||||
`--rms_mix_rate`: The RMS mix rate. (Use the volume envelope of the input to replace or mix with the volume envelope of the output. The closer the ratio is to 1, the more the output envelope is used)
|
||||
|
||||
`--protect`: The protect value. (Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but it may reduce indexing accuracy:)
|
||||
|
||||
|
||||
### Example:
|
||||
|
||||
```bash
|
||||
python fakeyou_rvc_tts_infer.py --tts_model_path "path/to/tts/model" --tts_config_path "path/to/tts/config" --text "Hello, World" --model_path "path/to/vc/model" --input_audio_filename "path/to/input/audio.wav" --output_audio_filename "path/to/output/audio.wav"
|
||||
```
|
||||
@@ -0,0 +1,403 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# [Retrieval-based-Voice-Conversion-WebUI](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI) Training notebook"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ZFFCx5J80SGa"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/Retrieval_based_Voice_Conversion_WebUI.ipynb)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "GmFP6bN9dvOq"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 查看显卡\n",
|
||||
"!nvidia-smi"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "jwu07JgqoFON"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 挂载谷歌云盘\n",
|
||||
"\n",
|
||||
"from google.colab import drive\n",
|
||||
"\n",
|
||||
"drive.mount(\"/content/drive\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "wjddIFr1oS3W"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 安装依赖\n",
|
||||
"!apt-get -y install build-essential python3-dev ffmpeg\n",
|
||||
"!pip3 install --upgrade setuptools wheel\n",
|
||||
"!pip3 install --upgrade pip\n",
|
||||
"!pip3 install faiss-cpu==1.7.2 fairseq gradio==3.14.0 ffmpeg ffmpeg-python praat-parselmouth pyworld numpy==1.23.5 numba==0.56.4 librosa==0.9.2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "ge_97mfpgqTm"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 克隆仓库\n",
|
||||
"\n",
|
||||
"!git clone --depth=1 -b stable https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI\n",
|
||||
"%cd /content/Retrieval-based-Voice-Conversion-WebUI\n",
|
||||
"!mkdir -p pretrained uvr5_weights"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "BLDEZADkvlw1"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 更新仓库(一般无需执行)\n",
|
||||
"!git pull"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "pqE0PrnuRqI2"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 安装aria2\n",
|
||||
"!apt -y install -qq aria2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "UG3XpUwEomUz"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 下载底模\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D48k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G48k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D48k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G48k.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "HugjmZqZRuiF"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 下载人声分离模型\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP2-人声vocals+非人声instrumentals.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/uvr5_weights -o HP2-人声vocals+非人声instrumentals.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP5-主旋律人声vocals+其他instrumentals.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/uvr5_weights -o HP5-主旋律人声vocals+其他instrumentals.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "2RCaT9FTR0ej"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 下载hubert_base\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt -d /content/Retrieval-based-Voice-Conversion-WebUI -o hubert_base.pt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #下载rmvpe模型\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt -d /content/Retrieval-based-Voice-Conversion-WebUI -o rmvpe.pt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "Mwk7Q0Loqzjx"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 从谷歌云盘加载打包好的数据集到/content/dataset\n",
|
||||
"\n",
|
||||
"# @markdown 数据集位置\n",
|
||||
"DATASET = (\n",
|
||||
" \"/content/drive/MyDrive/dataset/lulu20230327_32k.zip\" # @param {type:\"string\"}\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"!mkdir -p /content/dataset\n",
|
||||
"!unzip -d /content/dataset -B {DATASET}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "PDlFxWHWEynD"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 重命名数据集中的重名文件\n",
|
||||
"!ls -a /content/dataset/\n",
|
||||
"!rename 's/(\\w+)\\.(\\w+)~(\\d*)/$1_$3.$2/' /content/dataset/*.*~*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "7vh6vphDwO0b"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 启动web\n",
|
||||
"%cd /content/Retrieval-based-Voice-Conversion-WebUI\n",
|
||||
"# %load_ext tensorboard\n",
|
||||
"# %tensorboard --logdir /content/Retrieval-based-Voice-Conversion-WebUI/logs\n",
|
||||
"!python3 infer-web.py --colab --pycmd python3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "FgJuNeAwx5Y_"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 手动将训练后的模型文件备份到谷歌云盘\n",
|
||||
"# @markdown 需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",
|
||||
"\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 模型epoch\n",
|
||||
"MODELEPOCH = 9600 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/added_*.index /content/drive/MyDrive/\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/total_*.npy /content/drive/MyDrive/\n",
|
||||
"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "OVQoLQJXS7WX"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 从谷歌云盘恢复pth\n",
|
||||
"# @markdown 需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",
|
||||
"\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 模型epoch\n",
|
||||
"MODELEPOCH = 7500 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
|
||||
"\n",
|
||||
"!cp /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/drive/MyDrive/*.index /content/\n",
|
||||
"!cp /content/drive/MyDrive/*.npy /content/\n",
|
||||
"!cp /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "ZKAyuKb9J6dz"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 手动预处理(不推荐)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 采样率\n",
|
||||
"BITRATE = 48000 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 使用的进程数\n",
|
||||
"THREADCOUNT = 8 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!python3 trainset_preprocess_pipeline_print.py /content/dataset {BITRATE} {THREADCOUNT} logs/{MODELNAME} True"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "CrxJqzAUKmPJ"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 手动提取特征(不推荐)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 使用的进程数\n",
|
||||
"THREADCOUNT = 8 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 音高提取算法\n",
|
||||
"ALGO = \"harvest\" # @param {type:\"string\"}\n",
|
||||
"\n",
|
||||
"!python3 extract_f0_print.py logs/{MODELNAME} {THREADCOUNT} {ALGO}\n",
|
||||
"\n",
|
||||
"!python3 extract_feature_print.py cpu 1 0 0 logs/{MODELNAME}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "IMLPLKOaKj58"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 手动训练(不推荐)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 使用的GPU\n",
|
||||
"USEGPU = \"0\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 批大小\n",
|
||||
"BATCHSIZE = 32 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 停止的epoch\n",
|
||||
"MODELEPOCH = 3200 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 保存epoch间隔\n",
|
||||
"EPOCHSAVE = 100 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 采样率\n",
|
||||
"MODELSAMPLE = \"48k\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 是否缓存训练集\n",
|
||||
"CACHEDATA = 1 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 是否仅保存最新的ckpt文件\n",
|
||||
"ONLYLATEST = 0 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!python3 train_nsf_sim_cache_sid_load_pretrain.py -e lulu -sr {MODELSAMPLE} -f0 1 -bs {BATCHSIZE} -g {USEGPU} -te {MODELEPOCH} -se {EPOCHSAVE} -pg pretrained/f0G{MODELSAMPLE}.pth -pd pretrained/f0D{MODELSAMPLE}.pth -l {ONLYLATEST} -c {CACHEDATA}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "haYA81hySuDl"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 删除其它pth,只留选中的(慎点,仔细看代码)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 选中模型epoch\n",
|
||||
"MODELEPOCH = 9600 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!echo \"备份选中的模型。。。\"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"正在删除。。。\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
|
||||
"!rm /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*.pth\n",
|
||||
"\n",
|
||||
"!echo \"恢复选中的模型。。。\"\n",
|
||||
"!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
|
||||
"!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"删除完成\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "QhSiPTVPoIRh"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 清除项目下所有文件,只留选中的模型(慎点,仔细看代码)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 选中模型epoch\n",
|
||||
"MODELEPOCH = 9600 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!echo \"备份选中的模型。。。\"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"正在删除。。。\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
|
||||
"!rm -rf /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*\n",
|
||||
"\n",
|
||||
"!echo \"恢复选中的模型。。。\"\n",
|
||||
"!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
|
||||
"!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"删除完成\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"accelerator": "GPU",
|
||||
"colab": {
|
||||
"private_outputs": true,
|
||||
"provenance": []
|
||||
},
|
||||
"gpuClass": "standard",
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# [Retrieval-based-Voice-Conversion-WebUI](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI) Training notebook"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ZFFCx5J80SGa"
|
||||
},
|
||||
"source": [
|
||||
"[](https://colab.research.google.com/github/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/Retrieval_based_Voice_Conversion_WebUI_v2.ipynb)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "GmFP6bN9dvOq"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #查看显卡\n",
|
||||
"!nvidia-smi"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "jwu07JgqoFON"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 挂载谷歌云盘\n",
|
||||
"\n",
|
||||
"from google.colab import drive\n",
|
||||
"\n",
|
||||
"drive.mount(\"/content/drive\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "wjddIFr1oS3W"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #安装依赖\n",
|
||||
"!apt-get -y install build-essential python3-dev ffmpeg\n",
|
||||
"!pip3 install --upgrade setuptools wheel\n",
|
||||
"!pip3 install --upgrade pip\n",
|
||||
"!pip3 install faiss-cpu==1.7.2 fairseq gradio==3.14.0 ffmpeg ffmpeg-python praat-parselmouth pyworld numpy==1.23.5 numba==0.56.4 librosa==0.9.2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "ge_97mfpgqTm"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #克隆仓库\n",
|
||||
"\n",
|
||||
"!mkdir Retrieval-based-Voice-Conversion-WebUI\n",
|
||||
"%cd /content/Retrieval-based-Voice-Conversion-WebUI\n",
|
||||
"!git init\n",
|
||||
"!git remote add origin https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git\n",
|
||||
"!git fetch origin cfd984812804ddc9247d65b14c82cd32e56c1133 --depth=1\n",
|
||||
"!git reset --hard FETCH_HEAD"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "BLDEZADkvlw1"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #更新仓库(一般无需执行)\n",
|
||||
"!git pull"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "pqE0PrnuRqI2"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #安装aria2\n",
|
||||
"!apt -y install -qq aria2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "UG3XpUwEomUz"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 下载底模\n",
|
||||
"\n",
|
||||
"# v1\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D48k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G48k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D48k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G40k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G48k.pth\n",
|
||||
"\n",
|
||||
"# v2\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o D32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o D40k.pth\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o D48k.pth\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o G32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o G40k.pth\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o G48k.pth\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0D32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0D40k.pth\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0D48k.pth\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0G32k.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0G40k.pth\n",
|
||||
"# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0G48k.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "HugjmZqZRuiF"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #下载人声分离模型\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP2-人声vocals+非人声instrumentals.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/uvr5_weights -o HP2-人声vocals+非人声instrumentals.pth\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP5-主旋律人声vocals+其他instrumentals.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/uvr5_weights -o HP5-主旋律人声vocals+其他instrumentals.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "2RCaT9FTR0ej"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #下载hubert_base\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt -d /content/Retrieval-based-Voice-Conversion-WebUI -o hubert_base.pt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #下载rmvpe模型\n",
|
||||
"!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt -d /content/Retrieval-based-Voice-Conversion-WebUI -o rmvpe.pt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "Mwk7Q0Loqzjx"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #从谷歌云盘加载打包好的数据集到/content/dataset\n",
|
||||
"\n",
|
||||
"# @markdown 数据集位置\n",
|
||||
"DATASET = (\n",
|
||||
" \"/content/drive/MyDrive/dataset/lulu20230327_32k.zip\" # @param {type:\"string\"}\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"!mkdir -p /content/dataset\n",
|
||||
"!unzip -d /content/dataset -B {DATASET}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "PDlFxWHWEynD"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #重命名数据集中的重名文件\n",
|
||||
"!ls -a /content/dataset/\n",
|
||||
"!rename 's/(\\w+)\\.(\\w+)~(\\d*)/$1_$3.$2/' /content/dataset/*.*~*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "7vh6vphDwO0b"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #启动webui\n",
|
||||
"%cd /content/Retrieval-based-Voice-Conversion-WebUI\n",
|
||||
"# %load_ext tensorboard\n",
|
||||
"# %tensorboard --logdir /content/Retrieval-based-Voice-Conversion-WebUI/logs\n",
|
||||
"!python3 infer-web.py --colab --pycmd python3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "FgJuNeAwx5Y_"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title #手动将训练后的模型文件备份到谷歌云盘\n",
|
||||
"# @markdown #需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",
|
||||
"\n",
|
||||
"# @markdown #模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown #模型epoch\n",
|
||||
"MODELEPOCH = 9600 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/added_*.index /content/drive/MyDrive/\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/total_*.npy /content/drive/MyDrive/\n",
|
||||
"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "OVQoLQJXS7WX"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 从谷歌云盘恢复pth\n",
|
||||
"# @markdown 需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",
|
||||
"\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 模型epoch\n",
|
||||
"MODELEPOCH = 7500 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
|
||||
"\n",
|
||||
"!cp /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/drive/MyDrive/*.index /content/\n",
|
||||
"!cp /content/drive/MyDrive/*.npy /content/\n",
|
||||
"!cp /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "ZKAyuKb9J6dz"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 手动预处理(不推荐)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 采样率\n",
|
||||
"BITRATE = 48000 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 使用的进程数\n",
|
||||
"THREADCOUNT = 8 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!python3 trainset_preprocess_pipeline_print.py /content/dataset {BITRATE} {THREADCOUNT} logs/{MODELNAME} True"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "CrxJqzAUKmPJ"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 手动提取特征(不推荐)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 使用的进程数\n",
|
||||
"THREADCOUNT = 8 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 音高提取算法\n",
|
||||
"ALGO = \"harvest\" # @param {type:\"string\"}\n",
|
||||
"\n",
|
||||
"!python3 extract_f0_print.py logs/{MODELNAME} {THREADCOUNT} {ALGO}\n",
|
||||
"\n",
|
||||
"!python3 extract_feature_print.py cpu 1 0 0 logs/{MODELNAME}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "IMLPLKOaKj58"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 手动训练(不推荐)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 使用的GPU\n",
|
||||
"USEGPU = \"0\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 批大小\n",
|
||||
"BATCHSIZE = 32 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 停止的epoch\n",
|
||||
"MODELEPOCH = 3200 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 保存epoch间隔\n",
|
||||
"EPOCHSAVE = 100 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 采样率\n",
|
||||
"MODELSAMPLE = \"48k\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 是否缓存训练集\n",
|
||||
"CACHEDATA = 1 # @param {type:\"integer\"}\n",
|
||||
"# @markdown 是否仅保存最新的ckpt文件\n",
|
||||
"ONLYLATEST = 0 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!python3 train_nsf_sim_cache_sid_load_pretrain.py -e lulu -sr {MODELSAMPLE} -f0 1 -bs {BATCHSIZE} -g {USEGPU} -te {MODELEPOCH} -se {EPOCHSAVE} -pg pretrained/f0G{MODELSAMPLE}.pth -pd pretrained/f0D{MODELSAMPLE}.pth -l {ONLYLATEST} -c {CACHEDATA}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "haYA81hySuDl"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 删除其它pth,只留选中的(慎点,仔细看代码)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 选中模型epoch\n",
|
||||
"MODELEPOCH = 9600 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!echo \"备份选中的模型。。。\"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"正在删除。。。\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
|
||||
"!rm /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*.pth\n",
|
||||
"\n",
|
||||
"!echo \"恢复选中的模型。。。\"\n",
|
||||
"!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
|
||||
"!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"删除完成\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "QhSiPTVPoIRh"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title 清除项目下所有文件,只留选中的模型(慎点,仔细看代码)\n",
|
||||
"# @markdown 模型名\n",
|
||||
"MODELNAME = \"lulu\" # @param {type:\"string\"}\n",
|
||||
"# @markdown 选中模型epoch\n",
|
||||
"MODELEPOCH = 9600 # @param {type:\"integer\"}\n",
|
||||
"\n",
|
||||
"!echo \"备份选中的模型。。。\"\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",
|
||||
"!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"正在删除。。。\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",
|
||||
"!rm -rf /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*\n",
|
||||
"\n",
|
||||
"!echo \"恢复选中的模型。。。\"\n",
|
||||
"!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",
|
||||
"!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",
|
||||
"\n",
|
||||
"!echo \"删除完成\"\n",
|
||||
"!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"accelerator": "GPU",
|
||||
"colab": {
|
||||
"private_outputs": true,
|
||||
"provenance": []
|
||||
},
|
||||
"gpuClass": "standard",
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
rvc:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: rvc
|
||||
volumes:
|
||||
- ./weights:/app/assets/weights
|
||||
- ./opt:/app/opt
|
||||
# - ./dataset:/app/dataset # you can use this folder in order to provide your dataset for model training
|
||||
ports:
|
||||
- 7865:7865
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
@@ -0,0 +1,186 @@
|
||||
name: pydml
|
||||
channels:
|
||||
- pytorch
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
|
||||
- defaults
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
|
||||
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
|
||||
dependencies:
|
||||
- abseil-cpp=20211102.0=hd77b12b_0
|
||||
- absl-py=1.3.0=py310haa95532_0
|
||||
- aiohttp=3.8.3=py310h2bbff1b_0
|
||||
- aiosignal=1.2.0=pyhd3eb1b0_0
|
||||
- async-timeout=4.0.2=py310haa95532_0
|
||||
- attrs=22.1.0=py310haa95532_0
|
||||
- blas=1.0=mkl
|
||||
- blinker=1.4=py310haa95532_0
|
||||
- bottleneck=1.3.5=py310h9128911_0
|
||||
- brotli=1.0.9=h2bbff1b_7
|
||||
- brotli-bin=1.0.9=h2bbff1b_7
|
||||
- brotlipy=0.7.0=py310h2bbff1b_1002
|
||||
- bzip2=1.0.8=he774522_0
|
||||
- c-ares=1.19.0=h2bbff1b_0
|
||||
- ca-certificates=2023.05.30=haa95532_0
|
||||
- cachetools=4.2.2=pyhd3eb1b0_0
|
||||
- certifi=2023.5.7=py310haa95532_0
|
||||
- cffi=1.15.1=py310h2bbff1b_3
|
||||
- charset-normalizer=2.0.4=pyhd3eb1b0_0
|
||||
- click=8.0.4=py310haa95532_0
|
||||
- colorama=0.4.6=py310haa95532_0
|
||||
- contourpy=1.0.5=py310h59b6b97_0
|
||||
- cryptography=39.0.1=py310h21b164f_0
|
||||
- cycler=0.11.0=pyhd3eb1b0_0
|
||||
- fonttools=4.25.0=pyhd3eb1b0_0
|
||||
- freetype=2.12.1=ha860e81_0
|
||||
- frozenlist=1.3.3=py310h2bbff1b_0
|
||||
- giflib=5.2.1=h8cc25b3_3
|
||||
- glib=2.69.1=h5dc1a3c_2
|
||||
- google-auth=2.6.0=pyhd3eb1b0_0
|
||||
- google-auth-oauthlib=0.4.4=pyhd3eb1b0_0
|
||||
- grpc-cpp=1.48.2=hf108199_0
|
||||
- grpcio=1.48.2=py310hf108199_0
|
||||
- gst-plugins-base=1.18.5=h9e645db_0
|
||||
- gstreamer=1.18.5=hd78058f_0
|
||||
- icu=58.2=ha925a31_3
|
||||
- idna=3.4=py310haa95532_0
|
||||
- intel-openmp=2023.1.0=h59b6b97_46319
|
||||
- jpeg=9e=h2bbff1b_1
|
||||
- kiwisolver=1.4.4=py310hd77b12b_0
|
||||
- krb5=1.19.4=h5b6d351_0
|
||||
- lerc=3.0=hd77b12b_0
|
||||
- libbrotlicommon=1.0.9=h2bbff1b_7
|
||||
- libbrotlidec=1.0.9=h2bbff1b_7
|
||||
- libbrotlienc=1.0.9=h2bbff1b_7
|
||||
- libclang=14.0.6=default_hb5a9fac_1
|
||||
- libclang13=14.0.6=default_h8e68704_1
|
||||
- libdeflate=1.17=h2bbff1b_0
|
||||
- libffi=3.4.4=hd77b12b_0
|
||||
- libiconv=1.16=h2bbff1b_2
|
||||
- libogg=1.3.5=h2bbff1b_1
|
||||
- libpng=1.6.39=h8cc25b3_0
|
||||
- libprotobuf=3.20.3=h23ce68f_0
|
||||
- libtiff=4.5.0=h6c2663c_2
|
||||
- libuv=1.44.2=h2bbff1b_0
|
||||
- libvorbis=1.3.7=he774522_0
|
||||
- libwebp=1.2.4=hbc33d0d_1
|
||||
- libwebp-base=1.2.4=h2bbff1b_1
|
||||
- libxml2=2.10.3=h0ad7f3c_0
|
||||
- libxslt=1.1.37=h2bbff1b_0
|
||||
- lz4-c=1.9.4=h2bbff1b_0
|
||||
- markdown=3.4.1=py310haa95532_0
|
||||
- markupsafe=2.1.1=py310h2bbff1b_0
|
||||
- matplotlib=3.7.1=py310haa95532_1
|
||||
- matplotlib-base=3.7.1=py310h4ed8f06_1
|
||||
- mkl=2023.1.0=h8bd8f75_46356
|
||||
- mkl-service=2.4.0=py310h2bbff1b_1
|
||||
- mkl_fft=1.3.6=py310h4ed8f06_1
|
||||
- mkl_random=1.2.2=py310h4ed8f06_1
|
||||
- multidict=6.0.2=py310h2bbff1b_0
|
||||
- munkres=1.1.4=py_0
|
||||
- numexpr=2.8.4=py310h2cd9be0_1
|
||||
- numpy=1.24.3=py310h055cbcc_1
|
||||
- numpy-base=1.24.3=py310h65a83cf_1
|
||||
- oauthlib=3.2.2=py310haa95532_0
|
||||
- openssl=1.1.1t=h2bbff1b_0
|
||||
- packaging=23.0=py310haa95532_0
|
||||
- pandas=1.5.3=py310h4ed8f06_0
|
||||
- pcre=8.45=hd77b12b_0
|
||||
- pillow=9.4.0=py310hd77b12b_0
|
||||
- pip=23.0.1=py310haa95532_0
|
||||
- ply=3.11=py310haa95532_0
|
||||
- protobuf=3.20.3=py310hd77b12b_0
|
||||
- pyasn1=0.4.8=pyhd3eb1b0_0
|
||||
- pyasn1-modules=0.2.8=py_0
|
||||
- pycparser=2.21=pyhd3eb1b0_0
|
||||
- pyjwt=2.4.0=py310haa95532_0
|
||||
- pyopenssl=23.0.0=py310haa95532_0
|
||||
- pyparsing=3.0.9=py310haa95532_0
|
||||
- pyqt=5.15.7=py310hd77b12b_0
|
||||
- pyqt5-sip=12.11.0=py310hd77b12b_0
|
||||
- pysocks=1.7.1=py310haa95532_0
|
||||
- python=3.10.11=h966fe2a_2
|
||||
- python-dateutil=2.8.2=pyhd3eb1b0_0
|
||||
- pytorch-mutex=1.0=cpu
|
||||
- pytz=2022.7=py310haa95532_0
|
||||
- pyyaml=6.0=py310h2bbff1b_1
|
||||
- qt-main=5.15.2=he8e5bd7_8
|
||||
- qt-webengine=5.15.9=hb9a9bb5_5
|
||||
- qtwebkit=5.212=h2bbfb41_5
|
||||
- re2=2022.04.01=hd77b12b_0
|
||||
- requests=2.29.0=py310haa95532_0
|
||||
- requests-oauthlib=1.3.0=py_0
|
||||
- rsa=4.7.2=pyhd3eb1b0_1
|
||||
- setuptools=67.8.0=py310haa95532_0
|
||||
- sip=6.6.2=py310hd77b12b_0
|
||||
- six=1.16.0=pyhd3eb1b0_1
|
||||
- sqlite=3.41.2=h2bbff1b_0
|
||||
- tbb=2021.8.0=h59b6b97_0
|
||||
- tensorboard=2.10.0=py310haa95532_0
|
||||
- tensorboard-data-server=0.6.1=py310haa95532_0
|
||||
- tensorboard-plugin-wit=1.8.1=py310haa95532_0
|
||||
- tk=8.6.12=h2bbff1b_0
|
||||
- toml=0.10.2=pyhd3eb1b0_0
|
||||
- tornado=6.2=py310h2bbff1b_0
|
||||
- tqdm=4.65.0=py310h9909e9c_0
|
||||
- typing_extensions=4.5.0=py310haa95532_0
|
||||
- tzdata=2023c=h04d1e81_0
|
||||
- urllib3=1.26.16=py310haa95532_0
|
||||
- vc=14.2=h21ff451_1
|
||||
- vs2015_runtime=14.27.29016=h5e58377_2
|
||||
- werkzeug=2.2.3=py310haa95532_0
|
||||
- wheel=0.38.4=py310haa95532_0
|
||||
- win_inet_pton=1.1.0=py310haa95532_0
|
||||
- xz=5.4.2=h8cc25b3_0
|
||||
- yaml=0.2.5=he774522_0
|
||||
- yarl=1.8.1=py310h2bbff1b_0
|
||||
- zlib=1.2.13=h8cc25b3_0
|
||||
- zstd=1.5.5=hd43e919_0
|
||||
- pip:
|
||||
- antlr4-python3-runtime==4.8
|
||||
- appdirs==1.4.4
|
||||
- audioread==3.0.0
|
||||
- bitarray==2.7.4
|
||||
- cython==0.29.35
|
||||
- decorator==5.1.1
|
||||
- fairseq==0.12.2
|
||||
- faiss-cpu==1.7.4
|
||||
- filelock==3.12.0
|
||||
- hydra-core==1.0.7
|
||||
- jinja2==3.1.2
|
||||
- joblib==1.2.0
|
||||
- lazy-loader==0.2
|
||||
- librosa==0.10.0.post2
|
||||
- llvmlite==0.40.0
|
||||
- lxml==4.9.2
|
||||
- mpmath==1.3.0
|
||||
- msgpack==1.0.5
|
||||
- networkx==3.1
|
||||
- noisereduce==2.0.1
|
||||
- numba==0.57.0
|
||||
- omegaconf==2.0.6
|
||||
- opencv-python==4.7.0.72
|
||||
- pooch==1.6.0
|
||||
- portalocker==2.7.0
|
||||
- pysimplegui==4.60.5
|
||||
- pywin32==306
|
||||
- pyworld==0.3.3
|
||||
- regex==2023.5.5
|
||||
- sacrebleu==2.3.1
|
||||
- scikit-learn==1.2.2
|
||||
- scipy==1.10.1
|
||||
- sounddevice==0.4.6
|
||||
- soundfile==0.12.1
|
||||
- soxr==0.3.5
|
||||
- sympy==1.12
|
||||
- tabulate==0.9.0
|
||||
- threadpoolctl==3.1.0
|
||||
- torch==2.0.0
|
||||
- torch-directml==0.2.0.dev230426
|
||||
- torchaudio==2.0.1
|
||||
- torchvision==0.15.1
|
||||
- wget==3.2
|
||||
prefix: D:\ProgramData\anaconda3_\envs\pydml
|
||||
@@ -0,0 +1,276 @@
|
||||
"""
|
||||
Our own copy of RVC's (somewhat difficult to use) script, `infer_batch_rvc.py`.
|
||||
"""
|
||||
import os, sys, pdb, torch
|
||||
|
||||
print("Env vars:")
|
||||
print(os.environ)
|
||||
|
||||
|
||||
def print_gpu_info():
|
||||
print('========================================')
|
||||
print('Python interpreter', sys.executable)
|
||||
print('PyTorch version', torch.__version__)
|
||||
print('CUDA Available?', torch.cuda.is_available())
|
||||
print('CUDA Device count', torch.cuda.device_count())
|
||||
print('CUDA architectures library was compiled for', torch.cuda.get_arch_list())
|
||||
|
||||
#try:
|
||||
# from tensorflow.python.client import device_lib
|
||||
# print('local devices', str(device_lib.list_local_devices()).replace("\n", "\n "))
|
||||
#except ImportError:
|
||||
# print('no tensorflow - cannot list devices')
|
||||
# pass
|
||||
print('========================================', flush=True)
|
||||
|
||||
print_gpu_info()
|
||||
|
||||
|
||||
now_dir = os.getcwd()
|
||||
sys.path.append(now_dir)
|
||||
import sys
|
||||
import torch
|
||||
import tqdm as tq
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self, device, is_half):
|
||||
self.device = device
|
||||
self.is_half = is_half
|
||||
self.n_cpu = 0
|
||||
self.gpu_name = None
|
||||
self.gpu_mem = None
|
||||
self.x_pad, self.x_query, self.x_center, self.x_max = self.device_config()
|
||||
|
||||
def device_config(self) -> tuple:
|
||||
if torch.cuda.is_available():
|
||||
i_device = int(self.device.split(":")[-1])
|
||||
self.gpu_name = torch.cuda.get_device_name(i_device)
|
||||
if (
|
||||
("16" in self.gpu_name and "V100" not in self.gpu_name.upper())
|
||||
or "P40" in self.gpu_name.upper()
|
||||
or "1060" in self.gpu_name
|
||||
or "1070" in self.gpu_name
|
||||
or "1080" in self.gpu_name
|
||||
):
|
||||
print("16系/10系显卡和P40强制单精度")
|
||||
self.is_half = False
|
||||
for config_file in ["32k.json", "40k.json", "48k.json"]:
|
||||
with open(f"configs/{config_file}", "r") as f:
|
||||
strr = f.read().replace("true", "false")
|
||||
with open(f"configs/{config_file}", "w") as f:
|
||||
f.write(strr)
|
||||
with open("trainset_preprocess_pipeline_print.py", "r") as f:
|
||||
strr = f.read().replace("3.7", "3.0")
|
||||
with open("trainset_preprocess_pipeline_print.py", "w") as f:
|
||||
f.write(strr)
|
||||
else:
|
||||
self.gpu_name = None
|
||||
self.gpu_mem = int(
|
||||
torch.cuda.get_device_properties(i_device).total_memory
|
||||
/ 1024
|
||||
/ 1024
|
||||
/ 1024
|
||||
+ 0.4
|
||||
)
|
||||
if self.gpu_mem <= 4:
|
||||
with open("trainset_preprocess_pipeline_print.py", "r") as f:
|
||||
strr = f.read().replace("3.7", "3.0")
|
||||
with open("trainset_preprocess_pipeline_print.py", "w") as f:
|
||||
f.write(strr)
|
||||
elif torch.backends.mps.is_available():
|
||||
print("没有发现支持的N卡, 使用MPS进行推理")
|
||||
self.device = "mps"
|
||||
else:
|
||||
print("没有发现支持的N卡, 使用CPU进行推理")
|
||||
self.device = "cpu"
|
||||
self.is_half = True
|
||||
|
||||
if self.n_cpu == 0:
|
||||
self.n_cpu = cpu_count()
|
||||
|
||||
if self.is_half:
|
||||
# 6G显存配置
|
||||
x_pad = 3
|
||||
x_query = 10
|
||||
x_center = 60
|
||||
x_max = 65
|
||||
else:
|
||||
# 5G显存配置
|
||||
x_pad = 1
|
||||
x_query = 6
|
||||
x_center = 38
|
||||
x_max = 41
|
||||
|
||||
if self.gpu_mem != None and self.gpu_mem <= 4:
|
||||
x_pad = 1
|
||||
x_query = 5
|
||||
x_center = 30
|
||||
x_max = 32
|
||||
|
||||
return x_pad, x_query, x_center, x_max
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Run VC inference')
|
||||
|
||||
parser.add_argument('--model_path', type=str, help='path to the .pth file', required=True)
|
||||
parser.add_argument('--model_index_path', type=str, help='path to the .index file (empty string for none)', required=False, default='')
|
||||
parser.add_argument('--hubert_model_path', type=str, help='path to the hubert model .pth file (default hubert_base.pt)',
|
||||
required=False, default='hubert_base.pt')
|
||||
|
||||
parser.add_argument('--input_audio_filename', type=str, help='source audio file', required=True)
|
||||
parser.add_argument('--output_audio_filename', type=str, help='result audio file', required=True)
|
||||
|
||||
########
|
||||
# Default values are taken from the Gradio UI
|
||||
########
|
||||
parser.add_argument('--f0_up_key', type=str,
|
||||
help='the f0 key for the input audio file(default "0")',
|
||||
required=False, default='0')
|
||||
parser.add_argument('--f0_method', type=str,
|
||||
help='f0 estimation method to use: harvest (default), crepe, or pm',
|
||||
required=False, default='harvest')
|
||||
parser.add_argument('--index_rate', type=float,
|
||||
help='The rate for the index (search feature ratio) (default 0.75)',
|
||||
required=False, default=0.75) # Gradio default 0.75
|
||||
parser.add_argument('--filter_radius', type=int,
|
||||
help='The radius of the filter. If >=3, apply median filtering to harvested pitch results. Represents the filter radius and can reduce breathiness. (default 3)',
|
||||
required=False, default=3) # Gradio default 3
|
||||
parser.add_argument('--resample_sr', type=int,
|
||||
help='The sample rate for resampling (post process). Set to zero for no resample. (default 0)',
|
||||
required=False, default=0)
|
||||
parser.add_argument('--rms_mix_rate', type=float,
|
||||
help='RMS mix rate. Use the volume envelope of the input to replace or mix with the volume envelope of the output. The closer the ratio to 1, the more the output envelope is used (default 0.25)',
|
||||
required=False, default=0.25) # Gradio default 0.25
|
||||
parser.add_argument('--protect', type=float,
|
||||
help='The protect value. Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but may reduce indexing accuracy (default 0.33 ???)',
|
||||
required=False, default=0.33) # Gradio default 0.33
|
||||
|
||||
# Device / precision
|
||||
parser.add_argument('--device', type=str, help='compute device (eg. "cuda:0"), default "cuda:0".', required=False, default='cuda:0')
|
||||
parser.add_argument('--is_half', type=bool, help='halfwidth tensors (default false)', required=False, default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
f0up_key = args.f0_up_key
|
||||
input_path = args.input_audio_filename
|
||||
index_path = args.model_index_path
|
||||
f0method = args.f0_method
|
||||
opt_path = args.output_audio_filename
|
||||
model_path = args.model_path
|
||||
index_rate = args.index_rate
|
||||
device = args.device
|
||||
is_half = args.is_half
|
||||
filter_radius = args.filter_radius
|
||||
resample_sr = args.resample_sr
|
||||
rms_mix_rate = args.rms_mix_rate
|
||||
protect = args.protect
|
||||
hubert_path = args.hubert_model_path
|
||||
|
||||
config = Config(device, is_half)
|
||||
now_dir = os.getcwd()
|
||||
sys.path.append(now_dir)
|
||||
from lib.train.vc_infer_pipeline import VC
|
||||
from lib.infer_pack.models import (
|
||||
SynthesizerTrnMs256NSFsid,
|
||||
SynthesizerTrnMs256NSFsid_nono,
|
||||
SynthesizerTrnMs768NSFsid,
|
||||
SynthesizerTrnMs768NSFsid_nono,
|
||||
)
|
||||
from lib.audio import load_audio
|
||||
from fairseq import checkpoint_utils
|
||||
from scipy.io import wavfile
|
||||
|
||||
hubert_model = None
|
||||
|
||||
|
||||
def load_hubert(hubert_path="hubert_base.pt"):
|
||||
global hubert_model
|
||||
models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task(
|
||||
[hubert_path],
|
||||
suffix="",
|
||||
)
|
||||
hubert_model = models[0]
|
||||
hubert_model = hubert_model.to(device)
|
||||
if is_half:
|
||||
hubert_model = hubert_model.half()
|
||||
else:
|
||||
hubert_model = hubert_model.float()
|
||||
hubert_model.eval()
|
||||
|
||||
|
||||
def vc_single(sid, input_audio, f0_up_key, f0_file, f0_method, file_index, index_rate, hubert_path="hubert_base.pt"):
|
||||
global tgt_sr, net_g, vc, hubert_model, version
|
||||
if input_audio is None:
|
||||
return "You need to upload an audio", None
|
||||
f0_up_key = int(f0_up_key)
|
||||
audio = load_audio(input_audio, 16000)
|
||||
times = [0, 0, 0]
|
||||
if hubert_model == None:
|
||||
load_hubert(hubert_path)
|
||||
if_f0 = cpt.get("f0", 1)
|
||||
# audio_opt=vc.pipeline(hubert_model,net_g,sid,audio,times,f0_up_key,f0_method,file_index,file_big_npy,index_rate,if_f0,f0_file=f0_file)
|
||||
audio_opt = vc.pipeline(
|
||||
hubert_model,
|
||||
net_g,
|
||||
sid,
|
||||
audio,
|
||||
input_audio,
|
||||
times,
|
||||
f0_up_key,
|
||||
f0_method,
|
||||
file_index,
|
||||
index_rate,
|
||||
if_f0,
|
||||
filter_radius,
|
||||
tgt_sr,
|
||||
resample_sr,
|
||||
rms_mix_rate,
|
||||
version,
|
||||
protect,
|
||||
f0_file=f0_file,
|
||||
)
|
||||
print(times)
|
||||
return audio_opt
|
||||
|
||||
|
||||
def get_vc(model_path):
|
||||
global n_spk, tgt_sr, net_g, vc, cpt, device, is_half, version
|
||||
print("loading pth %s" % model_path)
|
||||
cpt = torch.load(model_path, map_location="cpu")
|
||||
tgt_sr = cpt["config"][-1]
|
||||
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
||||
if_f0 = cpt.get("f0", 1)
|
||||
version = cpt.get("version", "v1")
|
||||
if version == "v1":
|
||||
if if_f0 == 1:
|
||||
net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=is_half)
|
||||
else:
|
||||
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
||||
elif version == "v2":
|
||||
if if_f0 == 1: #
|
||||
net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=is_half)
|
||||
else:
|
||||
net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
|
||||
del net_g.enc_q
|
||||
print(net_g.load_state_dict(cpt["weight"], strict=False)) # 不加这一行清不干净,真奇葩
|
||||
net_g.eval().to(device)
|
||||
if is_half:
|
||||
net_g = net_g.half()
|
||||
else:
|
||||
net_g = net_g.float()
|
||||
vc = VC(tgt_sr, config)
|
||||
n_spk = cpt["config"][-3]
|
||||
# return {"visible": True,"maximum": n_spk, "__type__": "update"}
|
||||
|
||||
|
||||
get_vc(model_path)
|
||||
|
||||
file_path = input_path
|
||||
wav_opt = vc_single(
|
||||
0, file_path, f0up_key, None, f0method, index_path, index_rate, hubert_path
|
||||
)
|
||||
out_path = opt_path
|
||||
wavfile.write(out_path, tgt_sr, wav_opt)
|
||||
@@ -0,0 +1,165 @@
|
||||
import os, sys, pdb, torch
|
||||
from piper import PiperVoice
|
||||
import wave
|
||||
import argparse
|
||||
from scipy.io import wavfile
|
||||
import tqdm as tq
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
|
||||
# Environment and GPU Info
|
||||
print("Env vars:")
|
||||
print(os.environ)
|
||||
print('========================================')
|
||||
print('Python interpreter', sys.executable)
|
||||
print('PyTorch version', torch.__version__)
|
||||
print('CUDA Available?', torch.cuda.is_available())
|
||||
print('CUDA Device count', torch.cuda.device_count())
|
||||
print('CUDA architectures library was compiled for', torch.cuda.get_arch_list())
|
||||
print('========================================', flush=True)
|
||||
|
||||
now_dir = os.getcwd()
|
||||
sys.path.append(now_dir)
|
||||
|
||||
# Config Class
|
||||
class Config:
|
||||
def __init__(self, device, is_half):
|
||||
self.device = device
|
||||
self.is_half = is_half
|
||||
self.n_cpu = 0
|
||||
self.gpu_name = None
|
||||
self.gpu_mem = None
|
||||
self.x_pad, self.x_query, self.x_center, self.x_max = self.device_config()
|
||||
|
||||
def device_config(self) -> tuple:
|
||||
if torch.cuda.is_available():
|
||||
i_device = int(self.device.split(":")[-1])
|
||||
self.gpu_name = torch.cuda.get_device_name(i_device)
|
||||
elif torch.backends.mps.is_available():
|
||||
self.device = "mps"
|
||||
else:
|
||||
self.device = "cpu"
|
||||
self.is_half = True
|
||||
if self.n_cpu == 0:
|
||||
self.n_cpu = cpu_count()
|
||||
if self.is_half:
|
||||
x_pad = 3
|
||||
x_query = 10
|
||||
x_center = 60
|
||||
x_max = 65
|
||||
else:
|
||||
x_pad = 1
|
||||
x_query = 6
|
||||
x_center = 38
|
||||
x_max = 41
|
||||
if self.gpu_mem != None and self.gpu_mem <= 4:
|
||||
x_pad = 1
|
||||
x_query = 5
|
||||
x_center = 30
|
||||
x_max = 32
|
||||
return x_pad, x_query, x_center, x_max
|
||||
|
||||
# Argument Parser
|
||||
parser = argparse.ArgumentParser(description='Run Piper-TTS and RVC inference')
|
||||
|
||||
# Arguments for Piper-TTS
|
||||
parser.add_argument('--tts_model_path', type=str, required=True)
|
||||
parser.add_argument('--tts_config_path', type=str, required=True)
|
||||
parser.add_argument('--text', type=str, required=True)
|
||||
|
||||
# Additional Arguments for Piper TTS
|
||||
parser.add_argument('--length_scale', type=float, required=False, default=1.0, help='Phoneme length scale for TTS')
|
||||
parser.add_argument('--noise_scale', type=float, required=False, default=0.5, help='Noise scale for TTS')
|
||||
parser.add_argument('--noise_w', type=float, required=False, default=0.3, help='Phoneme width noise for TTS')
|
||||
parser.add_argument('--sentence_silence', type=float, required=False, default=0.0, help='Seconds of silence after each sentence in TTS')
|
||||
|
||||
parser.add_argument('--model_path', type=str, required=True)
|
||||
parser.add_argument('--model_index_path', type=str, required=False, default='')
|
||||
parser.add_argument('--hubert_model_path', type=str, required=False, default='hubert_base.pt')
|
||||
parser.add_argument('--input_audio_filename', type=str, required=True)
|
||||
parser.add_argument('--output_audio_filename', type=str, required=True)
|
||||
parser.add_argument('--f0_up_key', type=str, required=False, default='0')
|
||||
parser.add_argument('--f0_method', type=str, required=False, default='harvest')
|
||||
parser.add_argument('--index_rate', type=float, required=False, default=0.75)
|
||||
parser.add_argument('--filter_radius', type=int, required=False, default=3)
|
||||
parser.add_argument('--resample_sr', type=int, required=False, default=0)
|
||||
parser.add_argument('--rms_mix_rate', type=float, required=False, default=0.25)
|
||||
parser.add_argument('--protect', type=float, required=False, default=0.33)
|
||||
parser.add_argument('--device', type=str, required=False, default='cuda:0')
|
||||
parser.add_argument('--is_half', type=bool, required=False, default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Load Piper Voice with additional settings
|
||||
voice = PiperVoice.load(model_path=args.tts_model_path, config_path=args.tts_config_path)
|
||||
synthesize_args = {
|
||||
"length_scale": args.length_scale,
|
||||
"noise_scale": args.noise_scale,
|
||||
"noise_w": args.noise_w,
|
||||
"sentence_silence": args.sentence_silence,
|
||||
}
|
||||
|
||||
with wave.open('temp.wav', "wb") as wav_file:
|
||||
voice.synthesize(args.text, wav_file, **synthesize_args)
|
||||
|
||||
config = Config(args.device, args.is_half)
|
||||
now_dir = os.getcwd()
|
||||
sys.path.append(now_dir)
|
||||
from lib.train.vc_infer_pipeline import VC
|
||||
from lib.infer_pack.models import SynthesizerTrnMs256NSFsid, SynthesizerTrnMs256NSFsid_nono, SynthesizerTrnMs768NSFsid, SynthesizerTrnMs768NSFsid_nono
|
||||
from lib.audio import load_audio
|
||||
from fairseq import checkpoint_utils
|
||||
|
||||
hubert_model = None
|
||||
|
||||
def load_hubert(hubert_path="hubert_base.pt"):
|
||||
global hubert_model
|
||||
models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task([hubert_path])
|
||||
hubert_model = models[0]
|
||||
hubert_model = hubert_model.to(args.device)
|
||||
if args.is_half:
|
||||
hubert_model = hubert_model.half()
|
||||
|
||||
def vc_single(sid, input_audio, f0_up_key, f0_file, f0_method, file_index, index_rate):
|
||||
global tgt_sr, net_g, vc, hubert_model, version
|
||||
if input_audio is None:
|
||||
return "You need to upload an audio", None
|
||||
f0_up_key = int(f0_up_key)
|
||||
audio = load_audio(input_audio, 16000)
|
||||
times = [0, 0, 0]
|
||||
if hubert_model == None:
|
||||
load_hubert()
|
||||
if_f0 = cpt.get("f0", 1)
|
||||
audio_opt = vc.pipeline(hubert_model, net_g, sid, audio, input_audio, times, f0_up_key, f0_method, file_index, index_rate, if_f0, args.filter_radius, tgt_sr, args.resample_sr, args.rms_mix_rate, version, args.protect, f0_file=f0_file)
|
||||
print(times)
|
||||
return audio_opt
|
||||
|
||||
def get_vc(model_path):
|
||||
global tgt_sr, net_g, vc, cpt, version
|
||||
cpt = torch.load(model_path, map_location="cpu")
|
||||
tgt_sr = cpt["config"][-1]
|
||||
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0]
|
||||
if_f0 = cpt.get("f0", 1)
|
||||
version = cpt.get("version", "v1")
|
||||
if version == "v1":
|
||||
if if_f0 == 1:
|
||||
net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=args.is_half)
|
||||
else:
|
||||
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
||||
elif version == "v2":
|
||||
if if_f0 == 1:
|
||||
net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=args.is_half)
|
||||
else:
|
||||
net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
|
||||
del net_g.enc_q
|
||||
net_g.load_state_dict(cpt["weight"], strict=False)
|
||||
net_g.eval().to(args.device)
|
||||
if args.is_half:
|
||||
net_g = net_g.half()
|
||||
vc = VC(tgt_sr, config)
|
||||
|
||||
get_vc(args.model_path)
|
||||
file_path = args.input_audio_filename
|
||||
wav_opt = vc_single(0, file_path, args.f0_up_key, None, args.f0_method, args.model_index_path, args.index_rate)
|
||||
out_path = args.output_audio_filename
|
||||
wavfile.write(out_path, tgt_sr, wav_opt)
|
||||
@@ -0,0 +1,2 @@
|
||||
runtime\python.exe gui_v1.py --pycmd runtime\python.exe --dml
|
||||
pause
|
||||
@@ -0,0 +1,2 @@
|
||||
runtime\python.exe gui_v1.py
|
||||
pause
|
||||
@@ -0,0 +1,2 @@
|
||||
runtime\python.exe infer-web.py --pycmd runtime\python.exe --port 7897 --dml
|
||||
pause
|
||||
@@ -0,0 +1,2 @@
|
||||
runtime\python.exe infer-web.py --pycmd runtime\python.exe --port 7897
|
||||
pause
|
||||
@@ -0,0 +1,772 @@
|
||||
import os
|
||||
import logging
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
os.environ["OMP_NUM_THREADS"] = "4"
|
||||
if sys.platform == "darwin":
|
||||
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
|
||||
|
||||
now_dir = os.getcwd()
|
||||
sys.path.append(now_dir)
|
||||
import multiprocessing
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Harvest(multiprocessing.Process):
|
||||
def __init__(self, inp_q, opt_q):
|
||||
multiprocessing.Process.__init__(self)
|
||||
self.inp_q = inp_q
|
||||
self.opt_q = opt_q
|
||||
|
||||
def run(self):
|
||||
import numpy as np
|
||||
import pyworld
|
||||
|
||||
while 1:
|
||||
idx, x, res_f0, n_cpu, ts = self.inp_q.get()
|
||||
f0, t = pyworld.harvest(
|
||||
x.astype(np.double),
|
||||
fs=16000,
|
||||
f0_ceil=1100,
|
||||
f0_floor=50,
|
||||
frame_period=10,
|
||||
)
|
||||
res_f0[idx] = f0
|
||||
if len(res_f0.keys()) >= n_cpu:
|
||||
self.opt_q.put(ts)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import json
|
||||
import multiprocessing
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
from multiprocessing import Queue, cpu_count
|
||||
from queue import Empty
|
||||
|
||||
import librosa
|
||||
from tools.torchgate import TorchGate
|
||||
import numpy as np
|
||||
import PySimpleGUI as sg
|
||||
import sounddevice as sd
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
import torchaudio.transforms as tat
|
||||
|
||||
import tools.rvc_for_realtime as rvc_for_realtime
|
||||
from i18n.i18n import I18nAuto
|
||||
|
||||
i18n = I18nAuto()
|
||||
device = rvc_for_realtime.config.device
|
||||
# device = torch.device(
|
||||
# "cuda"
|
||||
# if torch.cuda.is_available()
|
||||
# else ("mps" if torch.backends.mps.is_available() else "cpu")
|
||||
# )
|
||||
current_dir = os.getcwd()
|
||||
inp_q = Queue()
|
||||
opt_q = Queue()
|
||||
n_cpu = min(cpu_count(), 8)
|
||||
for _ in range(n_cpu):
|
||||
Harvest(inp_q, opt_q).start()
|
||||
|
||||
class GUIConfig:
|
||||
def __init__(self) -> None:
|
||||
self.pth_path: str = ""
|
||||
self.index_path: str = ""
|
||||
self.pitch: int = 0
|
||||
self.samplerate: int = 40000
|
||||
self.block_time: float = 1.0 # s
|
||||
self.buffer_num: int = 1
|
||||
self.threhold: int = -60
|
||||
self.crossfade_time: float = 0.04
|
||||
self.extra_time: float = 2.0
|
||||
self.I_noise_reduce = False
|
||||
self.O_noise_reduce = False
|
||||
self.rms_mix_rate = 0.0
|
||||
self.index_rate = 0.3
|
||||
self.n_cpu = min(n_cpu, 6)
|
||||
self.f0method = "harvest"
|
||||
self.sg_input_device = ""
|
||||
self.sg_output_device = ""
|
||||
|
||||
class GUI:
|
||||
def __init__(self) -> None:
|
||||
self.config = GUIConfig()
|
||||
self.flag_vc = False
|
||||
|
||||
self.launcher()
|
||||
|
||||
def load(self):
|
||||
input_devices, output_devices, _, _ = self.get_devices()
|
||||
try:
|
||||
with open("configs/config.json", "r") as j:
|
||||
data = json.load(j)
|
||||
data["pm"] = data["f0method"] == "pm"
|
||||
data["harvest"] = data["f0method"] == "harvest"
|
||||
data["crepe"] = data["f0method"] == "crepe"
|
||||
data["rmvpe"] = data["f0method"] == "rmvpe"
|
||||
except:
|
||||
with open("configs/config.json", "w") as j:
|
||||
data = {
|
||||
"pth_path": " ",
|
||||
"index_path": " ",
|
||||
"sg_input_device": input_devices[sd.default.device[0]],
|
||||
"sg_output_device": output_devices[sd.default.device[1]],
|
||||
"threhold": "-60",
|
||||
"pitch": "0",
|
||||
"index_rate": "0",
|
||||
"rms_mix_rate": "0",
|
||||
"block_time": "0.25",
|
||||
"crossfade_length": "0.04",
|
||||
"extra_time": "2",
|
||||
"f0method": "rmvpe",
|
||||
}
|
||||
data["pm"] = data["f0method"] == "pm"
|
||||
data["harvest"] = data["f0method"] == "harvest"
|
||||
data["crepe"] = data["f0method"] == "crepe"
|
||||
data["rmvpe"] = data["f0method"] == "rmvpe"
|
||||
return data
|
||||
|
||||
def launcher(self):
|
||||
data = self.load()
|
||||
sg.theme("LightBlue3")
|
||||
input_devices, output_devices, _, _ = self.get_devices()
|
||||
layout = [
|
||||
[
|
||||
sg.Frame(
|
||||
title=i18n("加载模型"),
|
||||
layout=[
|
||||
[
|
||||
sg.Input(
|
||||
default_text=data.get("pth_path", ""),
|
||||
key="pth_path",
|
||||
),
|
||||
sg.FileBrowse(
|
||||
i18n("选择.pth文件"),
|
||||
initial_folder=os.path.join(
|
||||
os.getcwd(), "assets/weights"
|
||||
),
|
||||
file_types=((". pth"),),
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Input(
|
||||
default_text=data.get("index_path", ""),
|
||||
key="index_path",
|
||||
),
|
||||
sg.FileBrowse(
|
||||
i18n("选择.index文件"),
|
||||
initial_folder=os.path.join(os.getcwd(), "logs"),
|
||||
file_types=((". index"),),
|
||||
),
|
||||
],
|
||||
],
|
||||
)
|
||||
],
|
||||
[
|
||||
sg.Frame(
|
||||
layout=[
|
||||
[
|
||||
sg.Text(i18n("输入设备")),
|
||||
sg.Combo(
|
||||
input_devices,
|
||||
key="sg_input_device",
|
||||
default_value=data.get("sg_input_device", ""),
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("输出设备")),
|
||||
sg.Combo(
|
||||
output_devices,
|
||||
key="sg_output_device",
|
||||
default_value=data.get("sg_output_device", ""),
|
||||
),
|
||||
],
|
||||
[sg.Button(i18n("重载设备列表"), key="reload_devices")],
|
||||
],
|
||||
title=i18n("音频设备(请使用同种类驱动)"),
|
||||
)
|
||||
],
|
||||
[
|
||||
sg.Frame(
|
||||
layout=[
|
||||
[
|
||||
sg.Text(i18n("响应阈值")),
|
||||
sg.Slider(
|
||||
range=(-60, 0),
|
||||
key="threhold",
|
||||
resolution=1,
|
||||
orientation="h",
|
||||
default_value=data.get("threhold", "-60"),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("音调设置")),
|
||||
sg.Slider(
|
||||
range=(-24, 24),
|
||||
key="pitch",
|
||||
resolution=1,
|
||||
orientation="h",
|
||||
default_value=data.get("pitch", "0"),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("Index Rate")),
|
||||
sg.Slider(
|
||||
range=(0.0, 1.0),
|
||||
key="index_rate",
|
||||
resolution=0.01,
|
||||
orientation="h",
|
||||
default_value=data.get("index_rate", "0"),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("响度因子")),
|
||||
sg.Slider(
|
||||
range=(0.0, 1.0),
|
||||
key="rms_mix_rate",
|
||||
resolution=0.01,
|
||||
orientation="h",
|
||||
default_value=data.get("rms_mix_rate", "0"),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("音高算法")),
|
||||
sg.Radio(
|
||||
"pm",
|
||||
"f0method",
|
||||
key="pm",
|
||||
default=data.get("pm", "") == True,
|
||||
enable_events=True,
|
||||
),
|
||||
sg.Radio(
|
||||
"harvest",
|
||||
"f0method",
|
||||
key="harvest",
|
||||
default=data.get("harvest", "") == True,
|
||||
enable_events=True,
|
||||
),
|
||||
sg.Radio(
|
||||
"crepe",
|
||||
"f0method",
|
||||
key="crepe",
|
||||
default=data.get("crepe", "") == True,
|
||||
enable_events=True,
|
||||
),
|
||||
sg.Radio(
|
||||
"rmvpe",
|
||||
"f0method",
|
||||
key="rmvpe",
|
||||
default=data.get("rmvpe", "") == True,
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
],
|
||||
title=i18n("常规设置"),
|
||||
),
|
||||
sg.Frame(
|
||||
layout=[
|
||||
[
|
||||
sg.Text(i18n("采样长度")),
|
||||
sg.Slider(
|
||||
range=(0.05, 2.4),
|
||||
key="block_time",
|
||||
resolution=0.01,
|
||||
orientation="h",
|
||||
default_value=data.get("block_time", "0.25"),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("harvest进程数")),
|
||||
sg.Slider(
|
||||
range=(1, n_cpu),
|
||||
key="n_cpu",
|
||||
resolution=1,
|
||||
orientation="h",
|
||||
default_value=data.get(
|
||||
"n_cpu", min(self.config.n_cpu, n_cpu)
|
||||
),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("淡入淡出长度")),
|
||||
sg.Slider(
|
||||
range=(0.01, 0.15),
|
||||
key="crossfade_length",
|
||||
resolution=0.01,
|
||||
orientation="h",
|
||||
default_value=data.get("crossfade_length", "0.04"),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(i18n("额外推理时长")),
|
||||
sg.Slider(
|
||||
range=(0.05, 5.00),
|
||||
key="extra_time",
|
||||
resolution=0.01,
|
||||
orientation="h",
|
||||
default_value=data.get("extra_time", "2.0"),
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Checkbox(
|
||||
i18n("输入降噪"),
|
||||
key="I_noise_reduce",
|
||||
enable_events=True,
|
||||
),
|
||||
sg.Checkbox(
|
||||
i18n("输出降噪"),
|
||||
key="O_noise_reduce",
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
],
|
||||
title=i18n("性能设置"),
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Button(i18n("开始音频转换"), key="start_vc"),
|
||||
sg.Button(i18n("停止音频转换"), key="stop_vc"),
|
||||
sg.Text(i18n("推理时间(ms):")),
|
||||
sg.Text("0", key="infer_time"),
|
||||
],
|
||||
]
|
||||
self.window = sg.Window("RVC - GUI", layout=layout, finalize=True)
|
||||
self.event_handler()
|
||||
|
||||
def event_handler(self):
|
||||
while True:
|
||||
event, values = self.window.read()
|
||||
if event == sg.WINDOW_CLOSED:
|
||||
self.flag_vc = False
|
||||
exit()
|
||||
if event == "reload_devices":
|
||||
prev_input = self.window["sg_input_device"].get()
|
||||
prev_output = self.window["sg_output_device"].get()
|
||||
input_devices, output_devices, _, _ = self.get_devices(update=True)
|
||||
if prev_input not in input_devices:
|
||||
self.config.sg_input_device = input_devices[0]
|
||||
else:
|
||||
self.config.sg_input_device = prev_input
|
||||
self.window["sg_input_device"].Update(values=input_devices)
|
||||
self.window["sg_input_device"].Update(
|
||||
value=self.config.sg_input_device
|
||||
)
|
||||
if prev_output not in output_devices:
|
||||
self.config.sg_output_device = output_devices[0]
|
||||
else:
|
||||
self.config.sg_output_device = prev_output
|
||||
self.window["sg_output_device"].Update(values=output_devices)
|
||||
self.window["sg_output_device"].Update(
|
||||
value=self.config.sg_output_device
|
||||
)
|
||||
if event == "start_vc" and self.flag_vc == False:
|
||||
if self.set_values(values) == True:
|
||||
logger.info("cuda_is_available: %s", torch.cuda.is_available())
|
||||
self.start_vc()
|
||||
settings = {
|
||||
"pth_path": values["pth_path"],
|
||||
"index_path": values["index_path"],
|
||||
"sg_input_device": values["sg_input_device"],
|
||||
"sg_output_device": values["sg_output_device"],
|
||||
"threhold": values["threhold"],
|
||||
"pitch": values["pitch"],
|
||||
"rms_mix_rate": values["rms_mix_rate"],
|
||||
"index_rate": values["index_rate"],
|
||||
"block_time": values["block_time"],
|
||||
"crossfade_length": values["crossfade_length"],
|
||||
"extra_time": values["extra_time"],
|
||||
"n_cpu": values["n_cpu"],
|
||||
"f0method": ["pm", "harvest", "crepe", "rmvpe"][
|
||||
[
|
||||
values["pm"],
|
||||
values["harvest"],
|
||||
values["crepe"],
|
||||
values["rmvpe"],
|
||||
].index(True)
|
||||
],
|
||||
}
|
||||
with open("configs/config.json", "w") as j:
|
||||
json.dump(settings, j)
|
||||
if event == "stop_vc" and self.flag_vc == True:
|
||||
self.flag_vc = False
|
||||
|
||||
# Parameter hot update
|
||||
if event == "threhold":
|
||||
self.config.threhold = values["threhold"]
|
||||
elif event == "pitch":
|
||||
self.config.pitch = values["pitch"]
|
||||
if hasattr(self, "rvc"):
|
||||
self.rvc.change_key(values["pitch"])
|
||||
elif event == "index_rate":
|
||||
self.config.index_rate = values["index_rate"]
|
||||
if hasattr(self, "rvc"):
|
||||
self.rvc.change_index_rate(values["index_rate"])
|
||||
elif event == "rms_mix_rate":
|
||||
self.config.rms_mix_rate = values["rms_mix_rate"]
|
||||
elif event in ["pm", "harvest", "crepe", "rmvpe"]:
|
||||
self.config.f0method = event
|
||||
elif event == "I_noise_reduce":
|
||||
self.config.I_noise_reduce = values["I_noise_reduce"]
|
||||
elif event == "O_noise_reduce":
|
||||
self.config.O_noise_reduce = values["O_noise_reduce"]
|
||||
elif event != "start_vc" and self.flag_vc == True:
|
||||
# Other parameters do not support hot update
|
||||
self.flag_vc = False
|
||||
|
||||
def set_values(self, values):
|
||||
if len(values["pth_path"].strip()) == 0:
|
||||
sg.popup(i18n("请选择pth文件"))
|
||||
return False
|
||||
if len(values["index_path"].strip()) == 0:
|
||||
sg.popup(i18n("请选择index文件"))
|
||||
return False
|
||||
pattern = re.compile("[^\x00-\x7F]+")
|
||||
if pattern.findall(values["pth_path"]):
|
||||
sg.popup(i18n("pth文件路径不可包含中文"))
|
||||
return False
|
||||
if pattern.findall(values["index_path"]):
|
||||
sg.popup(i18n("index文件路径不可包含中文"))
|
||||
return False
|
||||
self.set_devices(values["sg_input_device"], values["sg_output_device"])
|
||||
self.config.pth_path = values["pth_path"]
|
||||
self.config.index_path = values["index_path"]
|
||||
self.config.threhold = values["threhold"]
|
||||
self.config.pitch = values["pitch"]
|
||||
self.config.block_time = values["block_time"]
|
||||
self.config.crossfade_time = values["crossfade_length"]
|
||||
self.config.extra_time = values["extra_time"]
|
||||
self.config.I_noise_reduce = values["I_noise_reduce"]
|
||||
self.config.O_noise_reduce = values["O_noise_reduce"]
|
||||
self.config.rms_mix_rate = values["rms_mix_rate"]
|
||||
self.config.index_rate = values["index_rate"]
|
||||
self.config.n_cpu = values["n_cpu"]
|
||||
self.config.f0method = ["pm", "harvest", "crepe", "rmvpe"][
|
||||
[
|
||||
values["pm"],
|
||||
values["harvest"],
|
||||
values["crepe"],
|
||||
values["rmvpe"],
|
||||
].index(True)
|
||||
]
|
||||
return True
|
||||
|
||||
def start_vc(self):
|
||||
torch.cuda.empty_cache()
|
||||
self.flag_vc = True
|
||||
self.rvc = rvc_for_realtime.RVC(
|
||||
self.config.pitch,
|
||||
self.config.pth_path,
|
||||
self.config.index_path,
|
||||
self.config.index_rate,
|
||||
self.config.n_cpu,
|
||||
inp_q,
|
||||
opt_q,
|
||||
device,
|
||||
self.rvc if hasattr(self, "rvc") else None,
|
||||
)
|
||||
self.config.samplerate = self.rvc.tgt_sr
|
||||
self.zc = self.rvc.tgt_sr // 100
|
||||
self.block_frame = (
|
||||
int(np.round(self.config.block_time * self.config.samplerate / self.zc))
|
||||
* self.zc
|
||||
)
|
||||
self.block_frame_16k = 160 * self.block_frame // self.zc
|
||||
self.crossfade_frame = (
|
||||
int(
|
||||
np.round(
|
||||
self.config.crossfade_time * self.config.samplerate / self.zc
|
||||
)
|
||||
)
|
||||
* self.zc
|
||||
)
|
||||
self.sola_search_frame = self.zc
|
||||
self.extra_frame = (
|
||||
int(np.round(self.config.extra_time * self.config.samplerate / self.zc))
|
||||
* self.zc
|
||||
)
|
||||
self.input_wav: torch.Tensor = torch.zeros(
|
||||
self.extra_frame
|
||||
+ self.crossfade_frame
|
||||
+ self.sola_search_frame
|
||||
+ self.block_frame,
|
||||
device=device,
|
||||
dtype=torch.float32,
|
||||
)
|
||||
self.input_wav_res: torch.Tensor = torch.zeros(
|
||||
160 * self.input_wav.shape[0] // self.zc,
|
||||
device=device,
|
||||
dtype=torch.float32,
|
||||
)
|
||||
self.pitch: np.ndarray = np.zeros(
|
||||
self.input_wav.shape[0] // self.zc,
|
||||
dtype="int32",
|
||||
)
|
||||
self.pitchf: np.ndarray = np.zeros(
|
||||
self.input_wav.shape[0] // self.zc,
|
||||
dtype="float64",
|
||||
)
|
||||
self.sola_buffer: torch.Tensor = torch.zeros(
|
||||
self.crossfade_frame, device=device, dtype=torch.float32
|
||||
)
|
||||
self.nr_buffer: torch.Tensor = self.sola_buffer.clone()
|
||||
self.output_buffer: torch.Tensor = self.input_wav.clone()
|
||||
self.res_buffer: torch.Tensor = torch.zeros(
|
||||
2 * self.zc, device=device, dtype=torch.float32
|
||||
)
|
||||
self.valid_rate = 1 - (self.extra_frame - 1) / self.input_wav.shape[0]
|
||||
self.fade_in_window: torch.Tensor = (
|
||||
torch.sin(
|
||||
0.5
|
||||
* np.pi
|
||||
* torch.linspace(
|
||||
0.0,
|
||||
1.0,
|
||||
steps=self.crossfade_frame,
|
||||
device=device,
|
||||
dtype=torch.float32,
|
||||
)
|
||||
)
|
||||
** 2
|
||||
)
|
||||
self.fade_out_window: torch.Tensor = 1 - self.fade_in_window
|
||||
self.resampler = tat.Resample(
|
||||
orig_freq=self.config.samplerate, new_freq=16000, dtype=torch.float32
|
||||
).to(device)
|
||||
self.tg = TorchGate(
|
||||
sr=self.config.samplerate, n_fft=4 * self.zc, prop_decrease=0.9
|
||||
).to(device)
|
||||
thread_vc = threading.Thread(target=self.soundinput)
|
||||
thread_vc.start()
|
||||
|
||||
def soundinput(self):
|
||||
"""
|
||||
接受音频输入
|
||||
"""
|
||||
channels = 1 if sys.platform == "darwin" else 2
|
||||
with sd.Stream(
|
||||
channels=channels,
|
||||
callback=self.audio_callback,
|
||||
blocksize=self.block_frame,
|
||||
samplerate=self.config.samplerate,
|
||||
dtype="float32",
|
||||
):
|
||||
while self.flag_vc:
|
||||
time.sleep(self.config.block_time)
|
||||
logger.debug("Audio block passed.")
|
||||
logger.debug("ENDing VC")
|
||||
|
||||
def audio_callback(
|
||||
self, indata: np.ndarray, outdata: np.ndarray, frames, times, status
|
||||
):
|
||||
"""
|
||||
音频处理
|
||||
"""
|
||||
start_time = time.perf_counter()
|
||||
indata = librosa.to_mono(indata.T)
|
||||
if self.config.threhold > -60:
|
||||
rms = librosa.feature.rms(
|
||||
y=indata, frame_length=4 * self.zc, hop_length=self.zc
|
||||
)
|
||||
db_threhold = (
|
||||
librosa.amplitude_to_db(rms, ref=1.0)[0] < self.config.threhold
|
||||
)
|
||||
for i in range(db_threhold.shape[0]):
|
||||
if db_threhold[i]:
|
||||
indata[i * self.zc : (i + 1) * self.zc] = 0
|
||||
self.input_wav[: -self.block_frame] = self.input_wav[
|
||||
self.block_frame :
|
||||
].clone()
|
||||
self.input_wav[-self.block_frame :] = torch.from_numpy(indata).to(device)
|
||||
self.input_wav_res[: -self.block_frame_16k] = self.input_wav_res[
|
||||
self.block_frame_16k :
|
||||
].clone()
|
||||
# input noise reduction and resampling
|
||||
if self.config.I_noise_reduce:
|
||||
input_wav = self.input_wav[
|
||||
-self.crossfade_frame - self.block_frame - 2 * self.zc :
|
||||
]
|
||||
input_wav = self.tg(
|
||||
input_wav.unsqueeze(0), self.input_wav.unsqueeze(0)
|
||||
)[0, 2 * self.zc :]
|
||||
input_wav[: self.crossfade_frame] *= self.fade_in_window
|
||||
input_wav[: self.crossfade_frame] += (
|
||||
self.nr_buffer * self.fade_out_window
|
||||
)
|
||||
self.nr_buffer[:] = input_wav[-self.crossfade_frame :]
|
||||
input_wav = torch.cat(
|
||||
(self.res_buffer[:], input_wav[: self.block_frame])
|
||||
)
|
||||
self.res_buffer[:] = input_wav[-2 * self.zc :]
|
||||
self.input_wav_res[-self.block_frame_16k - 160 :] = self.resampler(
|
||||
input_wav
|
||||
)[160:]
|
||||
else:
|
||||
self.input_wav_res[-self.block_frame_16k - 160 :] = self.resampler(
|
||||
self.input_wav[-self.block_frame - 2 * self.zc :]
|
||||
)[160:]
|
||||
# infer
|
||||
f0_extractor_frame = self.block_frame_16k + 800
|
||||
if self.config.f0method == "rmvpe":
|
||||
f0_extractor_frame = 5120 * ((f0_extractor_frame - 1) // 5120 + 1)
|
||||
infer_wav = self.rvc.infer(
|
||||
self.input_wav_res,
|
||||
self.input_wav_res[-f0_extractor_frame:].cpu().numpy(),
|
||||
self.block_frame_16k,
|
||||
self.valid_rate,
|
||||
self.pitch,
|
||||
self.pitchf,
|
||||
self.config.f0method,
|
||||
)
|
||||
infer_wav = infer_wav[
|
||||
-self.crossfade_frame - self.sola_search_frame - self.block_frame :
|
||||
]
|
||||
# output noise reduction
|
||||
if self.config.O_noise_reduce:
|
||||
self.output_buffer[: -self.block_frame] = self.output_buffer[
|
||||
self.block_frame :
|
||||
].clone()
|
||||
self.output_buffer[-self.block_frame :] = infer_wav[-self.block_frame :]
|
||||
infer_wav = self.tg(
|
||||
infer_wav.unsqueeze(0), self.output_buffer.unsqueeze(0)
|
||||
).squeeze(0)
|
||||
# volume envelop mixing
|
||||
if self.config.rms_mix_rate < 1:
|
||||
rms1 = librosa.feature.rms(
|
||||
y=self.input_wav_res[-160 * infer_wav.shape[0] // self.zc :]
|
||||
.cpu()
|
||||
.numpy(),
|
||||
frame_length=640,
|
||||
hop_length=160,
|
||||
)
|
||||
rms1 = torch.from_numpy(rms1).to(device)
|
||||
rms1 = F.interpolate(
|
||||
rms1.unsqueeze(0),
|
||||
size=infer_wav.shape[0] + 1,
|
||||
mode="linear",
|
||||
align_corners=True,
|
||||
)[0, 0, :-1]
|
||||
rms2 = librosa.feature.rms(
|
||||
y=infer_wav[:].cpu().numpy(),
|
||||
frame_length=4 * self.zc,
|
||||
hop_length=self.zc,
|
||||
)
|
||||
rms2 = torch.from_numpy(rms2).to(device)
|
||||
rms2 = F.interpolate(
|
||||
rms2.unsqueeze(0),
|
||||
size=infer_wav.shape[0] + 1,
|
||||
mode="linear",
|
||||
align_corners=True,
|
||||
)[0, 0, :-1]
|
||||
rms2 = torch.max(rms2, torch.zeros_like(rms2) + 1e-3)
|
||||
infer_wav *= torch.pow(
|
||||
rms1 / rms2, torch.tensor(1 - self.config.rms_mix_rate)
|
||||
)
|
||||
# SOLA algorithm from https://github.com/yxlllc/DDSP-SVC
|
||||
conv_input = infer_wav[
|
||||
None, None, : self.crossfade_frame + self.sola_search_frame
|
||||
]
|
||||
cor_nom = F.conv1d(conv_input, self.sola_buffer[None, None, :])
|
||||
cor_den = torch.sqrt(
|
||||
F.conv1d(
|
||||
conv_input**2,
|
||||
torch.ones(1, 1, self.crossfade_frame, device=device),
|
||||
)
|
||||
+ 1e-8
|
||||
)
|
||||
if sys.platform == "darwin":
|
||||
_, sola_offset = torch.max(cor_nom[0, 0] / cor_den[0, 0])
|
||||
sola_offset = sola_offset.item()
|
||||
else:
|
||||
sola_offset = torch.argmax(cor_nom[0, 0] / cor_den[0, 0])
|
||||
logger.debug("sola_offset = %d", int(sola_offset))
|
||||
infer_wav = infer_wav[
|
||||
sola_offset : sola_offset + self.block_frame + self.crossfade_frame
|
||||
]
|
||||
infer_wav[: self.crossfade_frame] *= self.fade_in_window
|
||||
infer_wav[: self.crossfade_frame] += self.sola_buffer * self.fade_out_window
|
||||
self.sola_buffer[:] = infer_wav[-self.crossfade_frame :]
|
||||
if sys.platform == "darwin":
|
||||
outdata[:] = (
|
||||
infer_wav[: -self.crossfade_frame].cpu().numpy()[:, np.newaxis]
|
||||
)
|
||||
else:
|
||||
outdata[:] = (
|
||||
infer_wav[: -self.crossfade_frame].repeat(2, 1).t().cpu().numpy()
|
||||
)
|
||||
total_time = time.perf_counter() - start_time
|
||||
self.window["infer_time"].update(int(total_time * 1000))
|
||||
logger.info("Infer time: %.2f", total_time)
|
||||
|
||||
def get_devices(self, update: bool = True):
|
||||
"""获取设备列表"""
|
||||
if update:
|
||||
sd._terminate()
|
||||
sd._initialize()
|
||||
devices = sd.query_devices()
|
||||
hostapis = sd.query_hostapis()
|
||||
for hostapi in hostapis:
|
||||
for device_idx in hostapi["devices"]:
|
||||
devices[device_idx]["hostapi_name"] = hostapi["name"]
|
||||
input_devices = [
|
||||
f"{d['name']} ({d['hostapi_name']})"
|
||||
for d in devices
|
||||
if d["max_input_channels"] > 0
|
||||
]
|
||||
output_devices = [
|
||||
f"{d['name']} ({d['hostapi_name']})"
|
||||
for d in devices
|
||||
if d["max_output_channels"] > 0
|
||||
]
|
||||
input_devices_indices = [
|
||||
d["index"] if "index" in d else d["name"]
|
||||
for d in devices
|
||||
if d["max_input_channels"] > 0
|
||||
]
|
||||
output_devices_indices = [
|
||||
d["index"] if "index" in d else d["name"]
|
||||
for d in devices
|
||||
if d["max_output_channels"] > 0
|
||||
]
|
||||
return (
|
||||
input_devices,
|
||||
output_devices,
|
||||
input_devices_indices,
|
||||
output_devices_indices,
|
||||
)
|
||||
|
||||
def set_devices(self, input_device, output_device):
|
||||
"""设置输出设备"""
|
||||
(
|
||||
input_devices,
|
||||
output_devices,
|
||||
input_device_indices,
|
||||
output_device_indices,
|
||||
) = self.get_devices()
|
||||
sd.default.device[0] = input_device_indices[
|
||||
input_devices.index(input_device)
|
||||
]
|
||||
sd.default.device[1] = output_device_indices[
|
||||
output_devices.index(output_device)
|
||||
]
|
||||
logger.info("Input device: %s:%s", str(sd.default.device[0]), input_device)
|
||||
logger.info(
|
||||
"Output device: %s:%s", str(sd.default.device[1]), output_device
|
||||
)
|
||||
|
||||
gui = GUI()
|
||||
File diff suppressed because it is too large
Load Diff
+3885
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
[tool.poetry]
|
||||
name = "rvc-beta"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["lj1995"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
torch = "^2.0.0"
|
||||
torchaudio = "^2.0.1"
|
||||
Cython = "^0.29.34"
|
||||
gradio = "^3.34.0"
|
||||
future = "^0.18.3"
|
||||
pydub = "^0.25.1"
|
||||
soundfile = "^0.12.1"
|
||||
ffmpeg-python = "^0.2.0"
|
||||
tensorboardX = "^2.6"
|
||||
functorch = "^2.0.0"
|
||||
fairseq = "^0.12.2"
|
||||
faiss-cpu = "^1.7.2"
|
||||
Jinja2 = "^3.1.2"
|
||||
json5 = "^0.9.11"
|
||||
librosa = "0.9.1"
|
||||
llvmlite = "0.39.0"
|
||||
Markdown = "^3.4.3"
|
||||
matplotlib = "^3.7.1"
|
||||
matplotlib-inline = "^0.1.6"
|
||||
numba = "0.56.4"
|
||||
numpy = "1.23.5"
|
||||
scipy = "1.9.3"
|
||||
praat-parselmouth = "^0.4.3"
|
||||
Pillow = "9.3.0"
|
||||
pyworld = "^0.3.2"
|
||||
resampy = "^0.4.2"
|
||||
scikit-learn = "^1.2.2"
|
||||
starlette = "^0.27.0"
|
||||
tensorboard = "^2.12.1"
|
||||
tensorboard-data-server = "^0.7.0"
|
||||
tensorboard-plugin-wit = "^1.8.1"
|
||||
torchgen = "^0.0.1"
|
||||
tqdm = "^4.65.0"
|
||||
tornado = "^6.3"
|
||||
Werkzeug = "^2.2.3"
|
||||
uc-micro-py = "^1.0.1"
|
||||
sympy = "^1.11.1"
|
||||
tabulate = "^0.9.0"
|
||||
PyYAML = "^6.0"
|
||||
pyasn1 = "^0.4.8"
|
||||
pyasn1-modules = "^0.2.8"
|
||||
fsspec = "^2023.3.0"
|
||||
absl-py = "^1.4.0"
|
||||
audioread = "^3.0.0"
|
||||
uvicorn = "^0.21.1"
|
||||
colorama = "^0.4.6"
|
||||
torchcrepe = "0.0.20"
|
||||
python-dotenv = "^1.0.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
@@ -0,0 +1,48 @@
|
||||
tensorflow-rocm
|
||||
joblib>=1.1.0
|
||||
numba==0.56.4
|
||||
numpy==1.23.5
|
||||
scipy
|
||||
librosa==0.9.1
|
||||
llvmlite==0.39.0
|
||||
fairseq==0.12.2
|
||||
faiss-cpu==1.7.3
|
||||
gradio==3.34.0
|
||||
Cython
|
||||
pydub>=0.25.1
|
||||
soundfile>=0.12.1
|
||||
ffmpeg-python>=0.2.0
|
||||
tensorboardX
|
||||
Jinja2>=3.1.2
|
||||
json5
|
||||
Markdown
|
||||
matplotlib>=3.7.0
|
||||
matplotlib-inline>=0.1.3
|
||||
praat-parselmouth>=0.4.2
|
||||
Pillow>=9.1.1
|
||||
resampy>=0.4.2
|
||||
scikit-learn
|
||||
tensorboard
|
||||
tqdm>=4.63.1
|
||||
tornado>=6.1
|
||||
Werkzeug>=2.2.3
|
||||
uc-micro-py>=1.0.1
|
||||
sympy>=1.11.1
|
||||
tabulate>=0.8.10
|
||||
PyYAML>=6.0
|
||||
pyasn1>=0.4.8
|
||||
pyasn1-modules>=0.2.8
|
||||
fsspec>=2022.11.0
|
||||
absl-py>=1.2.0
|
||||
audioread
|
||||
uvicorn>=0.21.1
|
||||
colorama>=0.4.5
|
||||
pyworld==0.3.2
|
||||
httpx
|
||||
onnxruntime
|
||||
onnxruntime-gpu
|
||||
torchcrepe==0.0.20
|
||||
fastapi==0.88
|
||||
ffmpy==0.3.1
|
||||
python-dotenv>=1.0.0
|
||||
av
|
||||
@@ -0,0 +1,46 @@
|
||||
joblib>=1.1.0
|
||||
numba==0.56.4
|
||||
numpy==1.23.5
|
||||
scipy
|
||||
librosa==0.9.1
|
||||
llvmlite==0.39.0
|
||||
fairseq==0.12.2
|
||||
faiss-cpu==1.7.3
|
||||
gradio==3.34.0
|
||||
Cython
|
||||
pydub>=0.25.1
|
||||
soundfile>=0.12.1
|
||||
ffmpeg-python>=0.2.0
|
||||
tensorboardX
|
||||
Jinja2>=3.1.2
|
||||
json5
|
||||
Markdown
|
||||
matplotlib>=3.7.0
|
||||
matplotlib-inline>=0.1.3
|
||||
praat-parselmouth>=0.4.2
|
||||
Pillow>=9.1.1
|
||||
resampy>=0.4.2
|
||||
scikit-learn
|
||||
tensorboard
|
||||
tqdm>=4.63.1
|
||||
tornado>=6.1
|
||||
Werkzeug>=2.2.3
|
||||
uc-micro-py>=1.0.1
|
||||
sympy>=1.11.1
|
||||
tabulate>=0.8.10
|
||||
PyYAML>=6.0
|
||||
pyasn1>=0.4.8
|
||||
pyasn1-modules>=0.2.8
|
||||
fsspec>=2022.11.0
|
||||
absl-py>=1.2.0
|
||||
audioread
|
||||
uvicorn>=0.21.1
|
||||
colorama>=0.4.5
|
||||
pyworld==0.3.2
|
||||
httpx
|
||||
onnxruntime-directml
|
||||
torchcrepe==0.0.20
|
||||
fastapi==0.88
|
||||
ffmpy==0.3.1
|
||||
python-dotenv>=1.0.0
|
||||
av
|
||||
@@ -0,0 +1,54 @@
|
||||
torch==2.0.1a0
|
||||
intel_extension_for_pytorch==2.0.110+xpu
|
||||
torchvision==0.15.2a0
|
||||
https://github.com/Disty0/Retrieval-based-Voice-Conversion-WebUI/releases/download/torchaudio_wheels_for_ipex/torchaudio-2.0.2+31de77d-cp310-cp310-linux_x86_64.whl
|
||||
-f https://developer.intel.com/ipex-whl-stable-xpu
|
||||
joblib>=1.1.0
|
||||
numba==0.56.4
|
||||
numpy==1.23.5
|
||||
scipy
|
||||
librosa==0.9.1
|
||||
llvmlite==0.39.0
|
||||
fairseq==0.12.2
|
||||
faiss-cpu==1.7.3
|
||||
gradio==3.34.0
|
||||
Cython
|
||||
pydub>=0.25.1
|
||||
soundfile>=0.12.1
|
||||
ffmpeg-python>=0.2.0
|
||||
tensorboardX
|
||||
Jinja2>=3.1.2
|
||||
json5
|
||||
Markdown
|
||||
matplotlib>=3.7.0
|
||||
matplotlib-inline>=0.1.3
|
||||
praat-parselmouth>=0.4.2
|
||||
Pillow>=9.1.1
|
||||
resampy>=0.4.2
|
||||
scikit-learn
|
||||
tensorboard
|
||||
tqdm>=4.63.1
|
||||
tornado>=6.1
|
||||
Werkzeug>=2.2.3
|
||||
uc-micro-py>=1.0.1
|
||||
sympy>=1.11.1
|
||||
tabulate>=0.8.10
|
||||
PyYAML>=6.0
|
||||
pyasn1>=0.4.8
|
||||
pyasn1-modules>=0.2.8
|
||||
fsspec>=2022.11.0
|
||||
absl-py>=1.2.0
|
||||
audioread
|
||||
uvicorn>=0.21.1
|
||||
colorama>=0.4.5
|
||||
pyworld==0.3.2
|
||||
httpx
|
||||
onnxruntime; sys_platform == 'darwin'
|
||||
onnxruntime-gpu; sys_platform != 'darwin'
|
||||
torchcrepe==0.0.20
|
||||
fastapi==0.88
|
||||
ffmpy==0.3.1
|
||||
python-dotenv>=1.0.0
|
||||
av
|
||||
PySimpleGUI
|
||||
sounddevice
|
||||
@@ -0,0 +1,29 @@
|
||||
#1.Install torch from pytorch.org:
|
||||
#torch 2.0 with cuda 11.8
|
||||
#pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
||||
#torch 1.11.0 with cuda 11.3
|
||||
#pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
|
||||
einops
|
||||
fairseq
|
||||
flask
|
||||
flask_cors
|
||||
gin
|
||||
gin_config
|
||||
librosa
|
||||
local_attention
|
||||
matplotlib
|
||||
praat-parselmouth
|
||||
pyworld
|
||||
PyYAML
|
||||
resampy
|
||||
scikit_learn
|
||||
scipy
|
||||
SoundFile
|
||||
tensorboard
|
||||
tqdm
|
||||
wave
|
||||
PySimpleGUI
|
||||
sounddevice
|
||||
gradio
|
||||
noisereduce
|
||||
onnxruntime-directml
|
||||
@@ -0,0 +1,28 @@
|
||||
#1.Install torch from pytorch.org:
|
||||
#torch 2.0 with cuda 11.8
|
||||
#pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
||||
#torch 1.11.0 with cuda 11.3
|
||||
#pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
|
||||
einops
|
||||
fairseq
|
||||
flask
|
||||
flask_cors
|
||||
gin
|
||||
gin_config
|
||||
librosa
|
||||
local_attention
|
||||
matplotlib
|
||||
praat-parselmouth
|
||||
pyworld
|
||||
PyYAML
|
||||
resampy
|
||||
scikit_learn
|
||||
scipy
|
||||
SoundFile
|
||||
tensorboard
|
||||
tqdm
|
||||
wave
|
||||
PySimpleGUI
|
||||
sounddevice
|
||||
gradio
|
||||
noisereduce
|
||||
@@ -0,0 +1,47 @@
|
||||
joblib>=1.1.0
|
||||
numba==0.56.4
|
||||
numpy==1.23.5
|
||||
scipy
|
||||
librosa==0.9.1
|
||||
llvmlite==0.39.0
|
||||
fairseq==0.12.2
|
||||
faiss-cpu==1.7.3
|
||||
gradio==3.34.0
|
||||
Cython
|
||||
pydub>=0.25.1
|
||||
soundfile>=0.12.1
|
||||
ffmpeg-python>=0.2.0
|
||||
tensorboardX
|
||||
Jinja2>=3.1.2
|
||||
json5
|
||||
Markdown
|
||||
matplotlib>=3.7.0
|
||||
matplotlib-inline>=0.1.3
|
||||
praat-parselmouth>=0.4.2
|
||||
Pillow>=9.1.1
|
||||
resampy>=0.4.2
|
||||
scikit-learn
|
||||
tensorboard
|
||||
tqdm>=4.63.1
|
||||
tornado>=6.1
|
||||
Werkzeug>=2.2.3
|
||||
uc-micro-py>=1.0.1
|
||||
sympy>=1.11.1
|
||||
tabulate>=0.8.10
|
||||
PyYAML>=6.0
|
||||
pyasn1>=0.4.8
|
||||
pyasn1-modules>=0.2.8
|
||||
fsspec>=2022.11.0
|
||||
absl-py>=1.2.0
|
||||
audioread
|
||||
uvicorn>=0.21.1
|
||||
colorama>=0.4.5
|
||||
pyworld==0.3.2
|
||||
httpx
|
||||
onnxruntime; sys_platform == 'darwin'
|
||||
onnxruntime-gpu; sys_platform != 'darwin'
|
||||
torchcrepe==0.0.20
|
||||
fastapi==0.88
|
||||
ffmpy==0.3.1
|
||||
python-dotenv>=1.0.0
|
||||
av
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
# macOS specific env:
|
||||
export PYTORCH_ENABLE_MPS_FALLBACK=1
|
||||
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
|
||||
elif [[ "$(uname)" != "Linux" ]]; then
|
||||
echo "Unsupported operating system."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d ".venv" ]; then
|
||||
echo "Activate venv..."
|
||||
source .venv/bin/activate
|
||||
else
|
||||
echo "Create venv..."
|
||||
requirements_file="requirements.txt"
|
||||
|
||||
# Check if Python 3.8 is installed
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "Python 3 not found. Attempting to install 3.8..."
|
||||
if [[ "$(uname)" == "Darwin" ]] && command -v brew &> /dev/null; then
|
||||
brew install python@3.8
|
||||
elif [[ "$(uname)" == "Linux" ]] && command -v apt-get &> /dev/null; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install python3.8
|
||||
else
|
||||
echo "Please install Python 3.8 manually."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
|
||||
# Check if required packages are installed and install them if not
|
||||
if [ -f "${requirements_file}" ]; then
|
||||
installed_packages=$(python3 -m pip freeze)
|
||||
while IFS= read -r package; do
|
||||
[[ "${package}" =~ ^#.* ]] && continue
|
||||
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
|
||||
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
|
||||
echo "${package_name} not found. Attempting to install..."
|
||||
python3 -m pip install --upgrade "${package}"
|
||||
fi
|
||||
done < "${requirements_file}"
|
||||
else
|
||||
echo "${requirements_file} not found. Please ensure the requirements file with required packages exists."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Download models
|
||||
./tools/dlmodels.sh
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run the main script
|
||||
python3 infer-web.py --pycmd python3
|
||||
@@ -0,0 +1 @@
|
||||
python3.8 -m venv .venv
|
||||
Reference in New Issue
Block a user