Nick1 commited on
Commit
c156672
·
verified ·
1 Parent(s): 819b637

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -91,12 +91,12 @@ def create_vc_fn(model_name, tgt_sr, net_g, vc, if_f0, version, file_index):
91
  return "You need to upload an audio", None
92
  sampling_rate, audio = vc_upload
93
  duration = audio.shape[0] / sampling_rate
94
- if duration > 90 and spaces:
95
  return "Please upload an audio file that is less than 90 seconds. If you need to generate a longer audio file, please use Colab.", None
96
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
97
  if len(audio.shape) > 1:
98
  audio = librosa.to_mono(audio.transpose(1, 0))
99
- if sampling_rate != 1600000:
100
  audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
101
  elif vc_audio_mode == "TTS Audio":
102
  if len(tts_text) > 100 and spaces:
@@ -106,7 +106,7 @@ def create_vc_fn(model_name, tgt_sr, net_g, vc, if_f0, version, file_index):
106
  os.makedirs("output", exist_ok=True)
107
  os.makedirs(os.path.join("output", "tts"), exist_ok=True)
108
  asyncio.run(edge_tts.Communicate(tts_text, "-".join(tts_voice.split('-')[:-1])).save(os.path.join("output", "tts", "tts.mp3")))
109
- audio, sr = librosa.load(os.path.join("output", "tts", "tts.mp3"), sr=1600000, mono=True)
110
  vc_input = os.path.join("output", "tts", "tts.mp3")
111
  times = [0, 0, 0]
112
  f0_up_key = int(f0_up_key)
 
91
  return "You need to upload an audio", None
92
  sampling_rate, audio = vc_upload
93
  duration = audio.shape[0] / sampling_rate
94
+ if duration > 900 and spaces:
95
  return "Please upload an audio file that is less than 90 seconds. If you need to generate a longer audio file, please use Colab.", None
96
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
97
  if len(audio.shape) > 1:
98
  audio = librosa.to_mono(audio.transpose(1, 0))
99
+ if sampling_rate != 16000:
100
  audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
101
  elif vc_audio_mode == "TTS Audio":
102
  if len(tts_text) > 100 and spaces:
 
106
  os.makedirs("output", exist_ok=True)
107
  os.makedirs(os.path.join("output", "tts"), exist_ok=True)
108
  asyncio.run(edge_tts.Communicate(tts_text, "-".join(tts_voice.split('-')[:-1])).save(os.path.join("output", "tts", "tts.mp3")))
109
+ audio, sr = librosa.load(os.path.join("output", "tts", "tts.mp3"), sr=16000, mono=True)
110
  vc_input = os.path.join("output", "tts", "tts.mp3")
111
  times = [0, 0, 0]
112
  f0_up_key = int(f0_up_key)