mirror of
https://github.com/Mangio621/Mangio-RVC-Fork.git
synced 2025-12-16 11:37:44 +01:00
stftpshift overhaul + fixes
fixed cli traceback + implemented formant shifting fixed batch conversion
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
8.0
|
8.0
|
||||||
-1.2
|
0.8
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
16.0
|
32.0
|
||||||
9.8
|
9.8
|
||||||
@@ -388,6 +388,7 @@ def vc_multi(
|
|||||||
info, opt = vc_single(
|
info, opt = vc_single(
|
||||||
sid,
|
sid,
|
||||||
path,
|
path,
|
||||||
|
None,
|
||||||
f0_up_key,
|
f0_up_key,
|
||||||
None,
|
None,
|
||||||
f0_method,
|
f0_method,
|
||||||
@@ -2134,8 +2135,9 @@ with gr.Blocks(theme=gr.themes.Soft(), title='Mangio-RVC-Web 💻') as app:
|
|||||||
|
|
||||||
qfrency = gr.Slider(
|
qfrency = gr.Slider(
|
||||||
value=Quefrency,
|
value=Quefrency,
|
||||||
|
info="Default value is 1.0",
|
||||||
label="Quefrency for formant shifting",
|
label="Quefrency for formant shifting",
|
||||||
minimum=-16.0,
|
minimum=0.0,
|
||||||
maximum=16.0,
|
maximum=16.0,
|
||||||
step=0.1,
|
step=0.1,
|
||||||
visible=bool(DoFormant),
|
visible=bool(DoFormant),
|
||||||
@@ -2144,8 +2146,9 @@ with gr.Blocks(theme=gr.themes.Soft(), title='Mangio-RVC-Web 💻') as app:
|
|||||||
|
|
||||||
tmbre = gr.Slider(
|
tmbre = gr.Slider(
|
||||||
value=Timbre,
|
value=Timbre,
|
||||||
|
info="Default value is 1.0",
|
||||||
label="Timbre for formant shifting",
|
label="Timbre for formant shifting",
|
||||||
minimum=-16.0,
|
minimum=0.0,
|
||||||
maximum=16.0,
|
maximum=16.0,
|
||||||
step=0.1,
|
step=0.1,
|
||||||
visible=bool(DoFormant),
|
visible=bool(DoFormant),
|
||||||
|
|||||||
58
my_utils.py
58
my_utils.py
@@ -4,6 +4,7 @@ import numpy as np
|
|||||||
# import praatio
|
# import praatio
|
||||||
# import praatio.praat_scripts
|
# import praatio.praat_scripts
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
@@ -25,39 +26,61 @@ def load_audio(file, sr, DoFormant, Quefrency, Timbre):
|
|||||||
file_formanted = file.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
|
file_formanted = file.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
|
||||||
cursor.execute("SELECT Quefrency, Timbre, DoFormant FROM formant_data")
|
cursor.execute("SELECT Quefrency, Timbre, DoFormant FROM formant_data")
|
||||||
Quefrency, Timbre, DoFormant = cursor.fetchone()
|
Quefrency, Timbre, DoFormant = cursor.fetchone()
|
||||||
print(f"dofor={bool(DoFormant)} timbr={Timbre} quef={Quefrency}\n")
|
#print(f"dofor={bool(DoFormant)} timbr={Timbre} quef={Quefrency}\n")
|
||||||
if bool(DoFormant):
|
if bool(DoFormant):
|
||||||
|
numerator = round(random.uniform(1,4), 4)
|
||||||
# os.system(f"stftpitchshift -i {file} -q {Quefrency} -t {Timbre} -o {file_formanted}")
|
# 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('stftpitchshift -i "%s" -p 1.0 --rms -w 128 -v 8 -q %s -t %s -o "%s"' % (file, Quefrency, Timbre, file_formanted))
|
||||||
|
|
||||||
if not file.endswith(".wav"):
|
if not file.endswith(".wav"):
|
||||||
print(f"\nfile = {file}\n")
|
|
||||||
converting = (
|
if not os.path.isfile(f"{file_formanted}.wav"):
|
||||||
ffmpeg.input(file, threads = 0)
|
#print(f"\nfile = {file}\n")
|
||||||
.output(f"{file_formanted}.wav")
|
#print(f"\nfile_formanted = {file_formanted}\n")
|
||||||
.run(
|
converting = (
|
||||||
cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True
|
ffmpeg.input(file_formanted, threads = 0)
|
||||||
|
.output(f"{file_formanted}.wav")
|
||||||
|
.run(
|
||||||
|
cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
else:
|
||||||
print("formanting...")
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
file_formanted = f"{file_formanted}.wav" if not file_formanted.endswith(".wav") else file_formanted
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print(f" · Formanting {file_formanted}...\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
os.system(
|
os.system(
|
||||||
'stftpitchshift.exe -i "%s" -q %s -t %s -o "%sFORMANTED"'
|
'stftpitchshift.exe -i "%s" -q "%s" -t "%s" -o "%sFORMANTED_%s.wav"'
|
||||||
% (file_formanted, Quefrency, Timbre, file_formanted)
|
% (file_formanted, Quefrency, Timbre, file_formanted, str(numerator))
|
||||||
)
|
)
|
||||||
print("formanted!")
|
|
||||||
|
|
||||||
|
|
||||||
|
print(f" · Formanted {file_formanted}!\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# filepraat = (os.path.abspath(os.getcwd()) + '\\' + file).replace('/','\\')
|
# filepraat = (os.path.abspath(os.getcwd()) + '\\' + file).replace('/','\\')
|
||||||
# file_formantedpraat = ('"' + os.path.abspath(os.getcwd()) + '/' + 'formanted'.join(file_formanted) + '"').replace('/','\\')
|
# file_formantedpraat = ('"' + os.path.abspath(os.getcwd()) + '/' + 'formanted'.join(file_formanted) + '"').replace('/','\\')
|
||||||
|
#print("%sFORMANTED_%s.wav" % (file_formanted, str(numerator)))
|
||||||
|
|
||||||
out, _ = (
|
out, _ = (
|
||||||
ffmpeg.input("%sFORMANTED%s" % (file_formanted, ".wav"), threads=0)
|
ffmpeg.input("%sFORMANTED_%s.wav" % (file_formanted, str(numerator)), threads=0)
|
||||||
.output("-", format="f32le", acodec="pcm_f32le", ac=1, ar=sr)
|
.output("-", format="f32le", acodec="pcm_f32le", ac=1, ar=sr)
|
||||||
.run(
|
.run(
|
||||||
cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True
|
cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
os.remove("%sFORMANTED%s" % (file_formanted, ".wav"))
|
|
||||||
os.remove(f"{file_formanted}.wav")
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
out, _ = (
|
out, _ = (
|
||||||
@@ -70,5 +93,10 @@ def load_audio(file, sr, DoFormant, Quefrency, Timbre):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RuntimeError(f"Failed to load audio: {e}")
|
raise RuntimeError(f"Failed to load audio: {e}")
|
||||||
|
|
||||||
|
try: os.remove("%sFORMANTED_%s.wav" % (file_formanted, str(numerator)))
|
||||||
|
except OSError: pass; print("couldn't remove formanted type of file")
|
||||||
|
try: os.remove(file_formanted)
|
||||||
|
except OSError: pass; print("couldn't remove converted type of file")
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
return np.frombuffer(out, np.float32).flatten()
|
return np.frombuffer(out, np.float32).flatten()
|
||||||
|
|||||||
Reference in New Issue
Block a user