XiaoHei Studio commited on
Commit
41f245a
1 Parent(s): 2d30eab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -434,9 +434,9 @@ def vc_infer(output_format, sid, input_audio, sr, input_audio_path, vc_transform
434
  input_audio = librosa.to_mono(input_audio.transpose(1, 0))
435
  if sr != 44100:
436
  input_audio = librosa.resample(input_audio, orig_sr=sr, target_sr=44100)
437
- sf.write("/tmp/temp.wav", input_audio, 44100, format="wav")
438
  _audio = model.slice_inference(
439
- "/tmp/temp.wav",
440
  sid,
441
  vc_transform,
442
  slice_db,
@@ -490,7 +490,7 @@ def vc_fn(output_format, sid, input_audio, vc_transform, auto_f0, cluster_ratio,
490
  return "你还未加载聚类或特征检索模型,无法启用聚类/特征检索混合比例", None
491
  audio, sr = sf.read(input_audio)
492
  output_file_path = vc_infer(output_format, sid, audio, sr, input_audio, vc_transform, auto_f0, cluster_ratio, slice_db, noise_scale, pad_seconds, cl_num, lg_num, lgr_num, f0_predictor, enhancer_adaptive_key, cr_threshold, k_step, use_spk_mix, second_encoding, loudness_envelope_adjustment)
493
- os.remove("/tmp/temp.wav")
494
  return "Success", output_file_path
495
  except Exception as e:
496
  if debug:
@@ -536,13 +536,13 @@ def tts_fn(_text, _gender, _lang, _rate, _volume, output_format, sid, vc_transfo
536
  else:
537
  subprocess.run([r"python", "tts.py", _text, _lang, _rate, _volume])
538
  target_sr = 44100
539
- y, sr = librosa.load("/tmp/tts.wav")
540
  resampled_y = librosa.resample(y, orig_sr=sr, target_sr=target_sr)
541
- sf.write("/tmp/tts.wav", resampled_y, target_sr, subtype = "PCM_16")
542
- input_audio = "/tmp/tts.wav"
543
  audio, sr = sf.read(input_audio)
544
  output_file_path = vc_infer(output_format, sid, audio, sr, input_audio, vc_transform, auto_f0, cluster_ratio, slice_db, noise_scale, pad_seconds, cl_num, lg_num, lgr_num, f0_predictor, enhancer_adaptive_key, cr_threshold, k_step, use_spk_mix, second_encoding, loudness_envelope_adjustment)
545
- #os.remove("/tmp/tts.wav")
546
  return "Success", output_file_path
547
  except Exception as e:
548
  if debug:
 
434
  input_audio = librosa.to_mono(input_audio.transpose(1, 0))
435
  if sr != 44100:
436
  input_audio = librosa.resample(input_audio, orig_sr=sr, target_sr=44100)
437
+ sf.write("temp.wav", input_audio, 44100, format="wav")
438
  _audio = model.slice_inference(
439
+ "temp.wav",
440
  sid,
441
  vc_transform,
442
  slice_db,
 
490
  return "你还未加载聚类或特征检索模型,无法启用聚类/特征检索混合比例", None
491
  audio, sr = sf.read(input_audio)
492
  output_file_path = vc_infer(output_format, sid, audio, sr, input_audio, vc_transform, auto_f0, cluster_ratio, slice_db, noise_scale, pad_seconds, cl_num, lg_num, lgr_num, f0_predictor, enhancer_adaptive_key, cr_threshold, k_step, use_spk_mix, second_encoding, loudness_envelope_adjustment)
493
+ os.remove("temp.wav")
494
  return "Success", output_file_path
495
  except Exception as e:
496
  if debug:
 
536
  else:
537
  subprocess.run([r"python", "tts.py", _text, _lang, _rate, _volume])
538
  target_sr = 44100
539
+ y, sr = librosa.load("tts.wav")
540
  resampled_y = librosa.resample(y, orig_sr=sr, target_sr=target_sr)
541
+ sf.write("tts.wav", resampled_y, target_sr, subtype = "PCM_16")
542
+ input_audio = "tts.wav"
543
  audio, sr = sf.read(input_audio)
544
  output_file_path = vc_infer(output_format, sid, audio, sr, input_audio, vc_transform, auto_f0, cluster_ratio, slice_db, noise_scale, pad_seconds, cl_num, lg_num, lgr_num, f0_predictor, enhancer_adaptive_key, cr_threshold, k_step, use_spk_mix, second_encoding, loudness_envelope_adjustment)
545
+ #os.remove("tts.wav")
546
  return "Success", output_file_path
547
  except Exception as e:
548
  if debug: