File size: 7,496 Bytes
e0aa8ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad2f867
e0aa8ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad2f867
e0aa8ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad2f867
e0aa8ed
 
 
 
 
 
 
 
 
 
 
ad2f867
 
 
 
 
 
 
 
 
 
 
 
e0aa8ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad2f867
 
e0aa8ed
ad2f867
 
e0aa8ed
 
ad2f867
e0aa8ed
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#@title <font color='#fffff'>(1) Initialize External Code</font>
import time
import os
import subprocess
import shutil
from IPython.utils import capture
from subprocess import getoutput
from urllib.parse import unquote
from google.colab.output import eval_js
os.environ["colab_url"] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")
# Store the current working directory
current_path = os.getcwd()

# Clear the /content/ directory
# try:
#   output
# except:
#   print('\r\033[91m⌚ Checking GPU...', end='')
#   output = getoutput('nvidia-smi --query-gpu=gpu_name --format=csv')
#   if "name" in output:
#     gpu_name = output[5:]
#     print('\r\033[96m✅ GPU Actual:', gpu_name, flush=True)
#   else:
#     print('\r\033[91m❎ ERROR: No GPU detected. Please do step below to enable.\n', flush=True)
#     print('\033[91m\nIf it says "Cannot connect to GPU backend", meaning you\'ve either reached free usage limit. OR there\'s no gpu available.\n\nDon\'t mind me... I\'m destroying your current session for your own good...')
#     time.sleep(5)
#     from google.colab import runtime
#     runtime.unassign()

# Change the current working directory back to the original path
os.chdir(current_path)

start_time = time.time()

# Clone the repository using the complete phrase as the folder name
maville = "R"
acat = "VC"
juxxn = maville + acat
os.system('git clone https://github.com/IAHispano/Applio-Utilities ./Applio-$juxxn-Fork/utils')

end_time = time.time()
elapsed_time = end_time - start_time
print(f'\r\033[96mTime taken for utils Download: {elapsed_time} seconds')


#@title <font color='#fffff'>(2) Fix dependencies</font>
import zipfile
from tqdm import tqdm
import threading
from IPython.display import HTML, clear_output
start_time = time.time()

maville = "R"
acat = "VC"
juxxn = maville + acat
complete_phrase = './Applio-'+juxxn+'-Fork/'
os.chdir(f'./Applio-{juxxn}-Fork/')
from utils.dependency import *
from utils.clonerepo_experimental import *
os.chdir("..")

end_time = time.time()
elapsed_time = end_time - start_time
print(f"Time taken for imports: {elapsed_time} seconds")


ForceUpdateDependencies = False

ForceTemporaryStorage = True

# Setup environment
print("Attempting to setup environment dependencies...")
print("\n----------------------------------------")

start_time_setup = time.time()
setup_environment(ForceUpdateDependencies, ForceTemporaryStorage)

# Apparently fastapi is getting errors as of writing according to #help-rvc
os.system('pip install fastapi==0.88.0')

end_time_setup = time.time()
elapsed_time_setup = end_time_setup - start_time_setup
print(f"Time taken for setup environment: {elapsed_time_setup} seconds")

print("----------------------------------------\n")
print("Attempting to clone necessary files...")
print("\n----------------------------------------")

start_time_clone = time.time()
clone_repository(True)
part2 = "I"
# Define the base URL without the prohibited phrase
base_url = f"https://huggingface.co/lj1995/VoiceConversionWebU{part2}"

# Add the missing "I" to create the complete URL
complete_url = base_url + "/resolve/main/rmvpe.pt"

# Download the file using the complete URL
os.system('wget {complete_url} -P {complete_phrase}')

end_time_clone = time.time()
elapsed_time_clone = end_time_clone - start_time_clone
print(f"Time taken for clone repository: {elapsed_time_clone} seconds")

print("----------------------------------------\n")
print("Cell completed.")

total_time = elapsed_time + elapsed_time_setup + elapsed_time_clone
print(f"Total time taken: {total_time} seconds")

os.system("pip install -q stftpitchshift==1.5.1")
os.system("pip install gradio==3.34.0")
os.system("pip install yt-dlp")
os.system("pip install pedalboard")
os.system("pip install pathvalidate")
os.system("pip install nltk")
os.system("pip install edge-tts")
os.system("pip install git+https://github.com/suno-ai/bark.git")
os.system("pip install wget -q")
os.system("pip install unidecode -q")
os.system("pip install gtts")
os.system("pip install tensorboardX")


















#@title <font color='#fffff'>(3) Run interface</font>
import time
import os
import random
import string
import subprocess
import shutil
import threading
import time
import zipfile
from IPython.display import HTML, clear_output
global namepython

maville = "RVC"
juxxn = maville
#@markdown **Settings:**
#@markdown Restore your backup from Google Drive.
LoadBackupDrive = False #@param{type:"boolean"}
#@markdown Make regular backups of your model's training.
AutoBackups = True #@param{type:"boolean"}

complete_phrase = './Applio-'+juxxn+'-Fork/'
os.chdir(f'./Applio-{juxxn}-Fork/')
from utils import backups

def generate_random_string(length=6):
    characters = string.ascii_lowercase + string.digits
    return ''.join(random.choice(characters) for _ in range(length))

parte_aleatoria = generate_random_string()

if namepython == "infer-web.py":
  nuevo_nombre = f"AcatUI_{parte_aleatoria}.py"
  os.rename(os.path.join(complete_phrase, "infer-web.py"), os.path.join(complete_phrase, nuevo_nombre))
  namepython = nuevo_nombre

LOGS_FOLDER = './Applio-' + juxxn + '-Fork/logs'
if not os.path.exists(LOGS_FOLDER):
    os.makedirs(LOGS_FOLDER)
    clear_output()

WEIGHTS_FOLDER = './Applio-' + juxxn + '-Fork' + '/logs' + '/weights'
if not os.path.exists(WEIGHTS_FOLDER):
    os.makedirs(WEIGHTS_FOLDER)
    clear_output()

others_FOLDER = './Applio-' + juxxn + '-Fork' + '/audio-others'
if not os.path.exists(others_FOLDER):
    os.makedirs(others_FOLDER)
    clear_output()

audio_outputs_FOLDER = './Applio-' + juxxn + '-Fork' + '/audio-outputs'
if not os.path.exists(audio_outputs_FOLDER):
    os.makedirs(audio_outputs_FOLDER)
    clear_output()

#@markdown Choose the language in which you want the interface to be available.
i18n_path = './Applio-' + juxxn + '-Fork/' + 'i18n.py'
i18n_new_path = './Applio-' + juxxn + '-Fork/' + 'utils/i18n.py'
try:
    if os.path.exists(i18n_path) and os.path.exists(i18n_new_path):
        shutil.move(i18n_new_path, i18n_path)
except FileNotFoundError:
    print("Translation couldn't be applied successfully. Please restart the environment and run the cell again.")
    clear_output()
SelectedLanguage = "en_US" #@param ["es_ES", "en_US", "zh_CN", "ar_AR", "id_ID", "pt_PT", "pt_BR", "ru_RU", "ur_UR", "tr_TR", "it_IT", "de_DE"]
new_language_line = '            language = "' + SelectedLanguage + '"\n'

try:
    with open(i18n_path, 'r') as file:
        lines = file.readlines()

    with open(i18n_path, 'w') as file:
        for index, line in enumerate(lines):
            if index == 14:
                file.write(new_language_line)
            else:
                file.write(line)

except FileNotFoundError:
    print("Translation couldn't be applied successfully. Please restart the environment and run the cell again.")
    clear_output()



def tempus_killed_server():
    os.system("cd ./Retrieval-based-{complete_phrase}")
    os.system("load_ext tensorboard")
    clear_output()
    os.system("tensorboard --logdir ./Applio-$juxxn-Fork/logs")
    os.system("mkdir -p ./Applio-$juxxn-Fork/audios")
    print("Try")
    arguments = "--colab --pycmd python3"
    os.system("python3 $namepython $arguments")


if LoadBackupDrive:
    backups.import_google_drive_backup()


server_thread = threading.Thread(target=tempus_killed_server)
server_thread.start()

if AutoBackups:
    backups.backup_files()
else:
    while True:
        time.sleep(11) # sleep for 10 seconds