Spaces:
r3gm
/
Restarting

r3gm commited on
Commit
756825c
1 Parent(s): 7bc29af

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -249
app.py DELETED
@@ -1,249 +0,0 @@
1
- #@title <font color='#fffff'>(1) Initialize External Code</font>
2
- import time
3
- import os
4
- import subprocess
5
- import shutil
6
- from IPython.utils import capture
7
- from subprocess import getoutput
8
- from urllib.parse import unquote
9
- #from google.colab.output import eval_js
10
- #os.environ["colab_url"] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")
11
- # Store the current working directory
12
- current_path = os.getcwd()
13
-
14
- # Clear the /content/ directory
15
- # try:
16
- # output
17
- # except:
18
- # print('\r\033[91m⌚ Checking GPU...', end='')
19
- # output = getoutput('nvidia-smi --query-gpu=gpu_name --format=csv')
20
- # if "name" in output:
21
- # gpu_name = output[5:]
22
- # print('\r\033[96m✅ GPU Actual:', gpu_name, flush=True)
23
- # else:
24
- # print('\r\033[91m❎ ERROR: No GPU detected. Please do step below to enable.\n', flush=True)
25
- # 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...')
26
- # time.sleep(5)
27
- # from google.colab import runtime
28
- # runtime.unassign()
29
-
30
- # Change the current working directory back to the original path
31
- os.chdir(current_path)
32
-
33
- start_time = time.time()
34
-
35
- # Clone the repository using the complete phrase as the folder name
36
- maville = "R"
37
- acat = "VC"
38
- juxxn = maville + acat
39
- os.system('git clone https://github.com/IAHispano/Applio-Utilities ./Applio-RVC-Fork/utils')
40
-
41
- end_time = time.time()
42
- elapsed_time = end_time - start_time
43
- print(f'\r\033[96mTime taken for utils Download: {elapsed_time} seconds')
44
-
45
-
46
- #@title <font color='#fffff'>(2) Fix dependencies</font>
47
- import zipfile
48
- from tqdm import tqdm
49
- import threading
50
- from IPython.display import HTML, clear_output
51
- start_time = time.time()
52
-
53
- maville = "R"
54
- acat = "VC"
55
- juxxn = maville + acat
56
- complete_phrase = './Applio-RVC-Fork/'
57
- os.chdir(f'./Applio-RVC-Fork/')
58
- os.system('cd Applio-RVC-Fork')
59
- from utils.dependency import *
60
- from utils.clonerepo_experimental import *
61
- os.chdir("..")
62
-
63
- end_time = time.time()
64
- elapsed_time = end_time - start_time
65
- print(f"Time taken for imports: {elapsed_time} seconds")
66
-
67
-
68
- ForceUpdateDependencies = False
69
-
70
- ForceTemporaryStorage = True
71
-
72
- # Setup environment
73
- print("Attempting to setup environment dependencies...")
74
- print("\n----------------------------------------")
75
-
76
- start_time_setup = time.time()
77
- setup_environment(ForceUpdateDependencies, ForceTemporaryStorage)
78
-
79
- # Apparently fastapi is getting errors as of writing according to #help-rvc
80
- os.system('pip install fastapi==0.88.0')
81
-
82
- end_time_setup = time.time()
83
- elapsed_time_setup = end_time_setup - start_time_setup
84
- print(f"Time taken for setup environment: {elapsed_time_setup} seconds")
85
-
86
- print("----------------------------------------\n")
87
- print("Attempting to clone necessary files...")
88
- print("\n----------------------------------------")
89
-
90
- start_time_clone = time.time()
91
- clone_repository(True)
92
- part2 = "I"
93
- # Define the base URL without the prohibited phrase
94
- base_url = f"https://huggingface.co/lj1995/VoiceConversionWebU{part2}"
95
-
96
- # Add the missing "I" to create the complete URL
97
- complete_url = base_url + "/resolve/main/rmvpe.pt"
98
-
99
- # Download the file using the complete URL
100
- os.system('wget {complete_url} -P {complete_phrase}')
101
-
102
- end_time_clone = time.time()
103
- elapsed_time_clone = end_time_clone - start_time_clone
104
- print(f"Time taken for clone repository: {elapsed_time_clone} seconds")
105
-
106
- print("----------------------------------------\n")
107
- print("Cell completed.")
108
-
109
- total_time = elapsed_time + elapsed_time_setup + elapsed_time_clone
110
- print(f"Total time taken: {total_time} seconds")
111
-
112
- os.system("pip install -q stftpitchshift==1.5.1")
113
- os.system("pip install gradio==3.34.0")
114
- os.system("pip install yt-dlp")
115
- os.system("pip install pedalboard")
116
- os.system("pip install pathvalidate")
117
- os.system("pip install nltk")
118
- os.system("pip install edge-tts")
119
- os.system("pip install git+https://github.com/suno-ai/bark.git")
120
- os.system("pip install wget -q")
121
- os.system("pip install unidecode -q")
122
- os.system("pip install gtts")
123
- os.system("pip install tensorboardX")
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
- #@title <font color='#fffff'>(3) Run interface</font>
143
- import time
144
- import os
145
- import random
146
- import string
147
- import subprocess
148
- import shutil
149
- import threading
150
- import time
151
- import zipfile
152
- from IPython.display import HTML, clear_output
153
- global namepython
154
-
155
- maville = "RVC"
156
- juxxn = maville
157
- #@markdown **Settings:**
158
- #@markdown Restore your backup from Google Drive.
159
- LoadBackupDrive = False #@param{type:"boolean"}
160
- #@markdown Make regular backups of your model's training.
161
- AutoBackups = True #@param{type:"boolean"}
162
-
163
- complete_phrase = './Applio-RVC-Fork/'
164
- os.chdir(f'./Applio-RVC-Fork/')
165
- from utils import backups
166
-
167
- def generate_random_string(length=6):
168
- characters = string.ascii_lowercase + string.digits
169
- return ''.join(random.choice(characters) for _ in range(length))
170
-
171
- parte_aleatoria = generate_random_string()
172
-
173
- if namepython == "infer-web.py":
174
- nuevo_nombre = f"AcatUI_{parte_aleatoria}.py"
175
- os.rename(os.path.join(complete_phrase, "infer-web.py"), os.path.join(complete_phrase, nuevo_nombre))
176
- namepython = nuevo_nombre
177
-
178
- LOGS_FOLDER = './Applio-RVC-Fork/logs'
179
- if not os.path.exists(LOGS_FOLDER):
180
- os.makedirs(LOGS_FOLDER)
181
- clear_output()
182
-
183
- WEIGHTS_FOLDER = './Applio-RVC-Fork' + '/logs' + '/weights'
184
- if not os.path.exists(WEIGHTS_FOLDER):
185
- os.makedirs(WEIGHTS_FOLDER)
186
- clear_output()
187
-
188
- others_FOLDER = './Applio-RVC-Fork' + '/audio-others'
189
- if not os.path.exists(others_FOLDER):
190
- os.makedirs(others_FOLDER)
191
- clear_output()
192
-
193
- audio_outputs_FOLDER = './Applio-RVC-Fork' + '/audio-outputs'
194
- if not os.path.exists(audio_outputs_FOLDER):
195
- os.makedirs(audio_outputs_FOLDER)
196
- clear_output()
197
-
198
- #@markdown Choose the language in which you want the interface to be available.
199
- i18n_path = './Applio-RVC-Fork/' + 'i18n.py'
200
- i18n_new_path = './Applio-RVC-Fork/' + 'utils/i18n.py'
201
- try:
202
- if os.path.exists(i18n_path) and os.path.exists(i18n_new_path):
203
- shutil.move(i18n_new_path, i18n_path)
204
- except FileNotFoundError:
205
- print("Translation couldn't be applied successfully. Please restart the environment and run the cell again.")
206
- clear_output()
207
- 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"]
208
- new_language_line = ' language = "' + SelectedLanguage + '"\n'
209
-
210
- try:
211
- with open(i18n_path, 'r') as file:
212
- lines = file.readlines()
213
-
214
- with open(i18n_path, 'w') as file:
215
- for index, line in enumerate(lines):
216
- if index == 14:
217
- file.write(new_language_line)
218
- else:
219
- file.write(line)
220
-
221
- except FileNotFoundError:
222
- print("Translation couldn't be applied successfully. Please restart the environment and run the cell again.")
223
- clear_output()
224
-
225
-
226
-
227
- def tempus_killed_server():
228
- os.system("cd ./Retrieval-based-{complete_phrase}")
229
- os.system("load_ext tensorboard")
230
- clear_output()
231
- os.system("tensorboard --logdir ./Applio-RVC-Fork/logs")
232
- os.system("mkdir -p ./Applio-RVC-Fork/audios")
233
- print("Try")
234
- arguments = "--colab --pycmd python3"
235
- os.system("python3 $namepython $arguments")
236
-
237
-
238
- if LoadBackupDrive:
239
- backups.import_google_drive_backup()
240
-
241
-
242
- server_thread = threading.Thread(target=tempus_killed_server)
243
- server_thread.start()
244
-
245
- if AutoBackups:
246
- backups.backup_files()
247
- else:
248
- while True:
249
- time.sleep(11) # sleep for 10 seconds