From 5e3f19ca9a1e7f2541b57cd9eb2302c46fe7bb83 Mon Sep 17 00:00:00 2001 From: alexlnkp Date: Mon, 24 Jul 2023 23:59:28 +0700 Subject: [PATCH] patch for new fixes i made before remade system of reading the formant settings on startup (still janky as hell, going to remake with sql) fixed when value is true in the txt but the checkbox isn't checked. therefore, also fixed when other parts of formanting in the ui doesn't appear. my_utils.py now utilizes the stftpitchshift from local environment instead of globally installed one. --- infer-web.py | 21 ++++++++++++++------- my_utils.py | 5 ++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/infer-web.py b/infer-web.py index 4bb9c0b..2098c39 100644 --- a/infer-web.py +++ b/infer-web.py @@ -57,14 +57,21 @@ os.environ["TEMP"] = tmp warnings.filterwarnings("ignore") torch.manual_seed(114514) -DoFormant = False -Quefrency = 8.0 -Timbre = 1.2 +global DoFormant, Quefrency, Timbre -with open('formanting.txt', 'w+') as fsf: - fsf.truncate(0) - fsf.writelines([str(DoFormant) + '\n', str(Quefrency) + '\n', str(Timbre) + '\n']) +try: + with open('formanting.txt', 'r') as psx: + content = psx.readlines() + Quefrency, Timbre = content[1].split('\n')[0], content[2].split('\n')[0] + DoFormant = True if content[0].split('\n')[0] == 'True' else False + +except Exception: + with open('formanting.txt', 'w+') as fsf: + fsf.truncate(0) + DoFormant = False + Quefrency, Timbre = 8.0, 1.2 + fsf.writelines([str(DoFormant) + '\n', str(Quefrency) + '\n', str(Timbre) + '\n']) config = Config() @@ -2126,7 +2133,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app: ) formant_preset.change(fn=preset_apply, inputs=[formant_preset, qfrency, tmbre], outputs=[qfrency, tmbre]) - frmntbut = gr.Button("Apply", variant="primary", visible=False) + frmntbut = gr.Button("Apply", variant="primary", visible=DoFormant) formanting.change(fn=formant_enabled,inputs=[formanting,qfrency,tmbre,frmntbut,formant_preset,formant_refresh_button],outputs=[formanting,qfrency,tmbre,frmntbut,formant_preset,formant_refresh_button]) frmntbut.click(fn=formant_apply,inputs=[qfrency, tmbre], outputs=[qfrency, tmbre]) formant_refresh_button.click(fn=update_fshift_presets,inputs=[formant_preset, qfrency, tmbre],outputs=[formant_preset, qfrency, tmbre]) diff --git a/my_utils.py b/my_utils.py index 90eeb52..c939798 100644 --- a/my_utils.py +++ b/my_utils.py @@ -34,15 +34,14 @@ def load_audio(file, sr, DoFormant, Quefrency, Timbre): # os.system(f"stftpitchshift -i {file} -q {Quefrency} -t {Timbre} -o {file_formanted}") # print('stftpitchshift -i "%s" -p 1.0 --rms -w 128 -v 8 -q %s -t %s -o "%s"' % (file, Quefrency, Timbre, file_formanted)) print("formanting...") - os.system( - 'stftpitchshift -i "%s" -q %s -t %s -o "%sFORMANTED"' + 'runtime\Scripts\stftpitchshift.exe -i "%s" -q %s -t %s -o "%sFORMANTED"' % (file, Quefrency, Timbre, file_formanted) ) print("formanted!") # filepraat = (os.path.abspath(os.getcwd()) + '\\' + file).replace('/','\\') # file_formantedpraat = ('"' + os.path.abspath(os.getcwd()) + '/' + 'formanted'.join(file_formanted) + '"').replace('/','\\') - + out, _ = ( ffmpeg.input("%sFORMANTED%s" % (file_formanted, ".wav"), threads=0) .output("-", format="f32le", acodec="pcm_f32le", ac=1, ar=sr)