fixspeed bugs

This commit is contained in:
liuhaozhe6788
2023-06-26 13:28:18 +08:00
parent 9ef191d6df
commit 8af4354c53
2 changed files with 5 additions and 6 deletions

View File

@@ -8,8 +8,8 @@ from synthesizer.hparams import syn_hparams
import soundfile as sf
from parselmouth.praat import run_file
high_lim_speed_factor = 1.0
low_lim_speed_factor = 0.5
high_lim_speed_factor = 1.5
low_lim_speed_factor = 0.4
def AudioAnalysis(dir, file):
sound = os.path.join(dir, file)
@@ -48,13 +48,13 @@ def FixSpeed(totDur_ori: float,
if arRate_syn == 0:
print("exception!\n The speed factor is abnormal")
return audio_syn
return audio_syn, speed_factor
speed_factor = round(arRate_ori/arRate_syn, 2)
print(f"speed_factor = {speed_factor}")
if speed_factor > high_lim_speed_factor or\
speed_factor < low_lim_speed_factor:
print("exception!\n The speed factor is abnormal")
return audio_syn
return audio_syn, speed_factor
else:
out_file = os.path.join(path_syn, name_syn + "_{}".format(speed_factor) + suffix_syn)
audio.a_speed(audio_syn, speed_factor, out_file)

View File

@@ -37,8 +37,7 @@ colormap = np.array([
], dtype=np.float) / 255
default_text = \
"The North Wind and the Sun were disputing which was the stronger, "\
"when a traveler came along wrapped in a warm cloak."
"We have to reduce the number of plastic bags."