Sebastian commited on
Commit
ce8f18d
·
1 Parent(s): 0143b89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -75,7 +75,7 @@ def inference(
75
 
76
  start_time = time.time()
77
 
78
- # all_parts = []
79
  for j, text in enumerate(texts):
80
  for audio_frame in tts.tts_with_preset(
81
  text,
@@ -84,14 +84,14 @@ def inference(
84
  preset=preset,
85
  k=1
86
  ):
87
- # print("Time taken: ", time.time() - start_time)
88
- # all_parts.append(audio_frame)
89
- yield (24000, audio_frame.cpu().detach().numpy())
 
 
 
 
90
 
91
- # wav = torch.cat(all_parts, dim=0).unsqueeze(0)
92
- # print(wav.shape)
93
- # torchaudio.save("output.wav", wav.cpu(), 24000)
94
- # yield (None, gr.make_waveform(audio="output.wav",))
95
 
96
  def main():
97
  title = "Tortoise TTS 🐢"
@@ -133,8 +133,7 @@ def main():
133
  value="No",
134
  )
135
 
136
- output_audio = gr.Audio(label="streaming audio:", streaming=True, autoplay=True)
137
- # download_audio = gr.Audio(label="dowanload audio:")
138
  interface = gr.Interface(
139
  fn=inference,
140
  inputs=[
@@ -147,9 +146,9 @@ def main():
147
  ],
148
  title=title,
149
  description=description,
150
- outputs=[output_audio],
151
  )
152
- interface.queue().launch()
153
 
154
 
155
  if __name__ == "__main__":
 
75
 
76
  start_time = time.time()
77
 
78
+ all_parts = []
79
  for j, text in enumerate(texts):
80
  for audio_frame in tts.tts_with_preset(
81
  text,
 
84
  preset=preset,
85
  k=1
86
  ):
87
+ all_parts.append(audio_frame)
88
+
89
+ wav = torch.cat(all_parts, dim=0).unsqueeze(0)
90
+ output_file = "output.wav"
91
+ torchaudio.save(output_file, wav.cpu(), 24000)
92
+
93
+ return output_file
94
 
 
 
 
 
95
 
96
  def main():
97
  title = "Tortoise TTS 🐢"
 
133
  value="No",
134
  )
135
 
136
+ download_audio = gr.Audio(label="Download audio:", download=True)
 
137
  interface = gr.Interface(
138
  fn=inference,
139
  inputs=[
 
146
  ],
147
  title=title,
148
  description=description,
149
+ outputs=[download_audio],
150
  )
151
+ interface.launch()
152
 
153
 
154
  if __name__ == "__main__":