cdminix commited on
Commit
ad69c84
·
verified ·
1 Parent(s): 6b5e00f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -9,12 +9,14 @@ from tortoise.api import TextToSpeech
9
  from tortoise.utils.text import split_and_recombine_text
10
  from tortoise.utils.audio import load_audio, load_voice, load_voices
11
 
 
 
12
  @spaces.GPU
13
  def inference(
14
  text,
15
  reference_audio,
16
- seed,
17
  ):
 
18
  texts = split_and_recombine_text(text)
19
 
20
  start_time = time.time()
@@ -32,8 +34,9 @@ def inference(
32
 
33
  wav = torch.cat(all_parts, dim=0).unsqueeze(0)
34
  print(wav.shape)
35
- torchaudio.save("output.wav", wav.cpu(), 24000)
36
- yield (None, gr.make_waveform(audio="output.wav",))
 
37
 
38
  def main():
39
  title = "Tortoise TTS 🐢"
@@ -68,8 +71,6 @@ def main():
68
 
69
 
70
  if __name__ == "__main__":
71
- tts = TextToSpeech(kv_cache=True, use_deepspeed=True, half=True)
72
-
73
  with open("Tortoise_TTS_Runs_Scripts.log", "a") as f:
74
  f.write(
75
  f"\n\n-------------------------Tortoise TTS Scripts Logs, {datetime.now()}-------------------------\n"
 
9
  from tortoise.utils.text import split_and_recombine_text
10
  from tortoise.utils.audio import load_audio, load_voice, load_voices
11
 
12
+ tts = TextToSpeech(kv_cache=True)
13
+
14
  @spaces.GPU
15
  def inference(
16
  text,
17
  reference_audio,
 
18
  ):
19
+ output_wav_path = tempfile.mktemp(suffix=".wav")
20
  texts = split_and_recombine_text(text)
21
 
22
  start_time = time.time()
 
34
 
35
  wav = torch.cat(all_parts, dim=0).unsqueeze(0)
36
  print(wav.shape)
37
+ torchaudio.save(output_wav_path, wav.cpu(), 24000)
38
+
39
+ return output_wav_path
40
 
41
  def main():
42
  title = "Tortoise TTS 🐢"
 
71
 
72
 
73
  if __name__ == "__main__":
 
 
74
  with open("Tortoise_TTS_Runs_Scripts.log", "a") as f:
75
  f.write(
76
  f"\n\n-------------------------Tortoise TTS Scripts Logs, {datetime.now()}-------------------------\n"