Spaces:
Build error
Build error
Update app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251#@title <font color='#fffff'>(1) Initialize External Code</font>import timeimport osimport subprocessimport shutilfrom IPython.utils import capturefrom subprocess import getoutputfrom urllib.parse import unquotefrom google.colab.output import eval_jsos.environ["colab_url"] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")# Store the current working directorycurrent_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 pathos.chdir(current_path)start_time = time.time()!nvidia-smi# Clone the repository using the complete phrase as the folder namemaville = "R"acat = "VC"juxxn = maville + acat!git clone https://github.com/IAHispano/Applio-Utilities ./Applio-$juxxn-Fork/utilsend_time = time.time()elapsed_time = end_time - start_timeprint(f'\r\033[96mTime taken for utils Download: {elapsed_time} seconds')#@title <font color='#fffff'>(2) Fix dependencies</font>import zipfilefrom tqdm import tqdmimport threadingfrom IPython.display import HTML, clear_outputstart_time = time.time()maville = "R"acat = "VC"juxxn = maville + acatcomplete_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_timeprint(f"Time taken for imports: {elapsed_time} seconds")ForceUpdateDependencies = FalseForceTemporaryStorage = True# Setup environmentprint("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!pip install fastapi==0.88.0end_time_setup = time.time()elapsed_time_setup = end_time_setup - start_time_setupprint(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 phrasebase_url = f"https://huggingface.co/lj1995/VoiceConversionWebU{part2}"# Add the missing "I" to create the complete URLcomplete_url = base_url + "/resolve/main/rmvpe.pt"# Download the file using the complete URL!wget {complete_url} -P {complete_phrase}end_time_clone = time.time()elapsed_time_clone = end_time_clone - start_time_cloneprint(f"Time taken for clone repository: {elapsed_time_clone} seconds")print("----------------------------------------\n")print("Cell completed.")total_time = elapsed_time + elapsed_time_setup + elapsed_time_cloneprint(f"Total time taken: {total_time} seconds")!pip install -q stftpitchshift==1.5.1!pip install gradio==3.34.0!pip install yt-dlp!pip install pedalboard!pip install pathvalidate!pip install nltk!pip install edge-tts!pip install git+https://github.com/suno-ai/bark.git!pip install wget -q!pip install unidecode -q!pip install gtts!pip install pip install tensorboardXnamepython = "infer-web.py"#@title <font color='#fffff'>(3) Run interface</font>import timeimport osimport randomimport stringimport subprocessimport shutilimport threadingimport timeimport zipfilefrom IPython.display import HTML, clear_outputglobal namepythonmaville = "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 backupsdef generate_random_string(length=6):characters = string.ascii_lowercase + string.digitsreturn ''.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_nombreLOGS_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():%cd ./Retrieval-based-{complete_phrase}%load_ext tensorboardclear_output()%tensorboard --logdir ./Applio-$juxxn-Fork/logs!mkdir -p ./Applio-$juxxn-Fork/audiosprint("Try")arguments = "--colab --pycmd python3"!python3 $namepython $argumentsif 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
app.py+251