Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -71,14 +71,12 @@ def infer(text, sdp_ratio, noise_scale, noise_scale_w, length_scale, sid, model_
|
|
71 |
sf.write("tmp.wav", audio, 44100)
|
72 |
return audio
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
now = datetime.now(tz).strftime('%m%d%H%M%S')
|
77 |
-
return now
|
78 |
|
79 |
def convert_wav_to_mp3(wav_file):
|
|
|
80 |
os.makedirs('out', exist_ok=True)
|
81 |
-
now=now()
|
82 |
output_path_mp3 = os.path.join('out', f"{now}.mp3")
|
83 |
|
84 |
renamed_input_path = os.path.join('in', f"in.wav")
|
@@ -89,10 +87,10 @@ def convert_wav_to_mp3(wav_file):
|
|
89 |
return output_path_mp3
|
90 |
|
91 |
def tts_generator(text, sdp_ratio, noise_scale, noise_scale_w, length_scale, model):
|
92 |
-
global net_g,speakers
|
93 |
model_path = models[model]
|
94 |
net_g, _, _, _ = utils.load_checkpoint(model_path, net_g, None, skip_optimizer=True)
|
95 |
-
print(now
|
96 |
try:
|
97 |
with torch.no_grad():
|
98 |
audio = infer(text, sdp_ratio=sdp_ratio, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale, sid=speaker,model_dir=model)
|
|
|
71 |
sf.write("tmp.wav", audio, 44100)
|
72 |
return audio
|
73 |
|
74 |
+
tz = pytz.timezone('Asia/Shanghai')
|
75 |
+
now = datetime.now(tz).strftime('%m%d%H%M%S')
|
|
|
|
|
76 |
|
77 |
def convert_wav_to_mp3(wav_file):
|
78 |
+
global now
|
79 |
os.makedirs('out', exist_ok=True)
|
|
|
80 |
output_path_mp3 = os.path.join('out', f"{now}.mp3")
|
81 |
|
82 |
renamed_input_path = os.path.join('in', f"in.wav")
|
|
|
87 |
return output_path_mp3
|
88 |
|
89 |
def tts_generator(text, sdp_ratio, noise_scale, noise_scale_w, length_scale, model):
|
90 |
+
global net_g,speakers,now
|
91 |
model_path = models[model]
|
92 |
net_g, _, _, _ = utils.load_checkpoint(model_path, net_g, None, skip_optimizer=True)
|
93 |
+
print(now+text)
|
94 |
try:
|
95 |
with torch.no_grad():
|
96 |
audio = infer(text, sdp_ratio=sdp_ratio, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale, sid=speaker,model_dir=model)
|