Spaces:
Configuration error
Configuration error
Commit
·
95add38
1
Parent(s):
1ea2ba0
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,9 +25,10 @@ from infer import *
|
|
| 25 |
import logging
|
| 26 |
from infer_tools.infer_tool import *
|
| 27 |
import io
|
|
|
|
| 28 |
|
| 29 |
clip_completed = False
|
| 30 |
-
def render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title2, choice, noise_step, use_mel_as_base):
|
| 31 |
logging.getLogger('numba').setLevel(logging.WARNING)
|
| 32 |
title = int(title)
|
| 33 |
title2 = int(title2)
|
|
@@ -43,12 +44,31 @@ def render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title
|
|
| 43 |
key = title # 音高调整,支持正负(半音)
|
| 44 |
# 加速倍数
|
| 45 |
pndm_speedup = 20
|
| 46 |
-
wav_gen='
|
| 47 |
|
| 48 |
# Show the spinner and run the run_clip function inside the 'with' block
|
| 49 |
with st.spinner("Rendering Audio..."):
|
| 50 |
f0_tst, f0_pred, audio = run_clip(svc_model,file_path=wav_fn, key=key, acc=title2, use_crepe=choice, use_pe=False, thre=0.05,
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
clip_completed = True
|
| 53 |
if clip_completed:
|
| 54 |
|
|
|
|
| 25 |
import logging
|
| 26 |
from infer_tools.infer_tool import *
|
| 27 |
import io
|
| 28 |
+
import parselmouth
|
| 29 |
|
| 30 |
clip_completed = False
|
| 31 |
+
def render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title2, title3, choice, noise_step, use_mel_as_base):
|
| 32 |
logging.getLogger('numba').setLevel(logging.WARNING)
|
| 33 |
title = int(title)
|
| 34 |
title2 = int(title2)
|
|
|
|
| 44 |
key = title # 音高调整,支持正负(半音)
|
| 45 |
# 加速倍数
|
| 46 |
pndm_speedup = 20
|
| 47 |
+
wav_gen='que.wav'
|
| 48 |
|
| 49 |
# Show the spinner and run the run_clip function inside the 'with' block
|
| 50 |
with st.spinner("Rendering Audio..."):
|
| 51 |
f0_tst, f0_pred, audio = run_clip(svc_model,file_path=wav_fn, key=key, acc=title2, use_crepe=choice, use_pe=False, thre=0.05,
|
| 52 |
+
##PRAAT
|
| 53 |
+
formant_shift_ratio_str = title3
|
| 54 |
+
formant_shift_ratio = float(formant_shift_ratio_str)
|
| 55 |
+
|
| 56 |
+
# If the formant shift ratio is not equal to 1.0, change the gender of the sound using parselmouth
|
| 57 |
+
if formant_shift_ratio != 1.0:
|
| 58 |
+
sound = parselmouth.Sound(wav_gen)
|
| 59 |
+
print(wav_gen)
|
| 60 |
+
Audio(data=sound.values, rate=sound.sampling_frequency)
|
| 61 |
+
sound.get_power()
|
| 62 |
+
sampling_rate = sound.sampling_frequency
|
| 63 |
+
print(sampling_rate)
|
| 64 |
+
resampled_sound = sound.resample(sampling_rate)
|
| 65 |
+
print(resampled_sound)
|
| 66 |
+
factor = formant_shift_ratio
|
| 67 |
+
print(factor)
|
| 68 |
+
manipulated_sound = call(sound, "Change gender", 75, 500, factor, 0, 1, 1)
|
| 69 |
+
print(manipulated_sound)
|
| 70 |
+
manipulated_sound.save("que.wav", "WAV")
|
| 71 |
+
print("Gender correct!") use_gt_mel=use_mel_as_base, add_noise_step=noise_step,project_name=project_name,out_path=wav_gen)
|
| 72 |
clip_completed = True
|
| 73 |
if clip_completed:
|
| 74 |
|