File size: 8,391 Bytes
5c13f7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
@echo off
Title Applio-RVC-Fork - Installer
setlocal
cd %~dp0

:::
:::                       _ _
:::     /\               | (_)
:::    /  \   _ __  _ __ | |_  ___
:::   / /\ \ | '_ \| '_ \| | |/ _ \
:::  / ____ \| |_) | |_) | | | (_) |
::: /_/    \_\ .__/| .__/|_|_|\___/
:::          | |   | |
:::          |_|   |_|
:::
:::

set "repoUrl=https://github.com/IAHispano/Applio-RVC-Fork.git"
set "repoFolder=Applio-RVC-Fork"
set "principal=%cd%\%repoFolder%"
set "runtime_scripts=%cd%\%repoFolder%\runtime\Scripts"
set "URL_BASE=https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main"
set "URL_EXTRA=https://huggingface.co/IAHispano/applio/resolve/main"
set "CONDA_ROOT_PREFIX=%UserProfile%\Miniconda3"
set "INSTALL_ENV_DIR=%principal%\env"
set "MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py39_23.9.0-0-Windows-x86_64.exe"
set "CONDA_EXECUTABLE=%CONDA_ROOT_PREFIX%\Scripts\conda.exe"

:processArguments
set "useManual=false"

for %%i in (%*) do (
    if /I "%%i"=="--manual" (
        set "useManual=true"
    ) else if /I "%%i"=="--condaNVDIA" (
        set "choice=1"
    ) else if /I "%%i"=="--condaDML" (
        set "choice=2"
    )
)

:endProcessArguments
if %useManual% == "false" (
    cls
    echo INFO: It's recommended to disable antivirus or firewall, as errors might occur when downloading pretrained models.
    echo.
    pause
    cls
)

net session >nul 2>&1
if %errorLevel% == 0 (
    echo You are executing the script with administrator privileges. Please run it without elevated permissions.
    echo Please, hit enter to exit.
    pause>nul
    exit
)

for /f "delims=: tokens=*" %%A in ('findstr /b ":::" "%~f0"') do @echo(%%A
echo.

git --version >nul 2>&1
if %errorlevel% equ 0 (
    echo Cloning the repository...
    git clone %repoUrl% %repoFolder%
    echo Moving the mingit folder...
    cd %repoFolder%
    del install_Applio.bat
    del Makefile
    del Dockerfile
    del docker-compose.yaml
    del stftpitchshift
    del /q *.sh
    cls

) else (
    if not exist "%cd%\mingit.zip" (
    echo Downloading MinGit from %URL_EXTRA%/mingit.zip
    curl -s -LJO %URL_EXTRA%/mingit.zip -o mingit.zip
    )

    if not exist "%cd%\mingit.zip" (
    echo Download failed, trying with the powershell method
    powershell -Command "& {Invoke-WebRequest -Uri '%URL_EXTRA%/mingit.zip' -OutFile 'mingit.zip'}"
    )

    if not exist "%cd%\mingit" (
        echo Extracting the file...
        powershell -command "& { Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory('%cd%\mingit.zip', '%cd%') }"
    )

    if not exist "%cd%\mingit" (
        echo Extracting failed trying with the tar method...
        tar -xf %cd%\mingit.zip
    )

    if exist "%cd%\mingit" (
        del mingit.zip
        echo Cloning the repository...
        %cd%\mingit\cmd\git.exe clone %repoUrl% %repoFolder%
        echo Moving the mingit folder...
        robocopy "%cd%\mingit" "%principal%\lib\tools\mingit" /e /move /dcopy:t > NUL
        if errorlevel 8 echo Warnings or errors occurred during the move.
        cd %repoFolder%
        del install_Applio.bat
        del Makefile
        del Dockerfile
        del docker-compose.yaml
        del stftpitchshift
        del /q *.sh
        cls
    ) else (
        echo Theres a problem extracting the file please download the file and extract it manually 
        echo https://huggingface.co/IAHispano/applio/resolve/main/mingit.zip
        pause
        exit
    )
)


if /I "%useManual%"=="true" goto :skipMenu

:menu
echo.
echo You can install Applio-RVC-Fork in various ways. The first method is highly recommended for most users, as it sets up all the dependencies in a virtual environment, preventing compatibility issues. The remaining options may be in experimental stages or cater to more advanced users.
echo.
echo Recommended for Nvidia/AMD/Intel GPU and non-GPU users:
echo [1] Download the dependencies using a Python virtual environment (Conda)
echo.
echo Recommended for AMD/Intel GPU users (Potentially buggy):
echo [2] Download the DML dependencies using a Python virtual environment (Conda)
echo.
echo [3] Skip dependency installation
echo.
set /p choice=Select the most appropriate option in your case (Option 1 is generally recommended): 
set choice=%choice: =%

:skipMenu
cls


if not exist "%cd%\env.zip" (
    echo Downloading the fairseq build from %URL_EXTRA%/env.zip
    curl -s -LJO %URL_EXTRA%/env.zip -o env.zip
)

if not exist "%cd%\env.zip" (
    echo Download failed, trying with the powershell method
    powershell -Command "& {Invoke-WebRequest -Uri '%URL_EXTRA%/env.zip' -OutFile 'mingit.zip'}"
)

if not exist "%cd%\env" (
    echo Extracting the file...
    powershell -command "& { Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory('%cd%\env.zip', '%cd%') }"
)

if not exist "%cd%\env" (
    echo Extracting failed trying with the tar method...
    tar -xf %cd%\env.zip
)

if exist "%cd%\env" (
    del env.zip
) else (
    echo Theres a problem extracting the file please download the file and extract it manually in the applio folder
    echo https://huggingface.co/IAHispano/applio/resolve/main/env.zip
    pause
    exit
)


if "%choice%"=="1" (
    cls
    if not exist "%CONDA_EXECUTABLE%" (
        echo Downloading Miniconda from %MINICONDA_DOWNLOAD_URL%
        curl %MINICONDA_DOWNLOAD_URL% -o miniconda.exe

        if not exist "%principal%\miniconda.exe" (
            echo Download failed trying with the powershell method
            powershell -Command "& {Invoke-WebRequest -Uri '%MINICONDA_DOWNLOAD_URL%' -OutFile 'miniconda.exe'}"
        )

        echo Installing Miniconda to %CONDA_ROOT_PREFIX%
        start /wait "" miniconda.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%CONDA_ROOT_PREFIX%
        del miniconda.exe
    )

    echo Packages to install: %PACKAGES_TO_INSTALL%
    call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" python=3.9
    echo Conda env installed !

    echo Installing the dependencies...
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%"
    conda install -c anaconda git -y
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" deactivate
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%"
    pip install --upgrade setuptools
    pip install -r "%principal%\assets\requirements\requirements.txt"
    pip install future==0.18.2
    pip uninstall torch torchvision torchaudio -y
    pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" deactivate
    goto dependenciesFinished
)

if "%choice%"=="2" (
    cls

    if not exist "%CONDA_EXECUTABLE%" (
        echo Downloading Miniconda from %MINICONDA_DOWNLOAD_URL%
        curl %MINICONDA_DOWNLOAD_URL% -o miniconda.exe

        if not exist "%principal%\miniconda.exe" (
            echo Download failed trying with the powershell method
            powershell -Command "& {Invoke-WebRequest -Uri '%MINICONDA_DOWNLOAD_URL%' -OutFile 'miniconda.exe'}"
        )

        echo Installing Miniconda to %CONDA_ROOT_PREFIX%
        start /wait "" miniconda.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%CONDA_ROOT_PREFIX%
        del miniconda.exe
    )

    echo Packages to install: %PACKAGES_TO_INSTALL%
    call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" python=3.9
    echo Conda env installed !

    echo Installing the dependencies...
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%"
    conda install -c anaconda git -y
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" deactivate
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%"
    pip uninstall onnxruntime onnxruntime-directml
    pip install -r "%principal%\assets\requirements\requirements-dml.txt"
    call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" deactivate
    goto dependenciesFinished
)

if "%choice%"=="3" (
    echo Dependencies successfully installed!
    echo.
    goto dependenciesFinished
)

:dependenciesFinished
cls 
echo Applio has been successfully downloaded, run the file go-applio.bat to run the web interface!
echo.
pause
exit