Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -175,14 +175,14 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, voice_clea
|
|
175 |
gpt_cond_latent,
|
176 |
speaker_embedding,)
|
177 |
try:
|
178 |
-
|
179 |
for i, chunk in enumerate(chunks):
|
|
|
180 |
print(f"Received chunk {i} of audio length {chunk.shape[-1]}")
|
181 |
out_file = f'{i}.wav'
|
182 |
write(out_file, 24000, chunk.detach().cpu().numpy().squeeze())
|
183 |
audio = AudioSegment.from_file(out_file)
|
184 |
audio.export(out_file, format='wav')
|
185 |
-
yield (
|
186 |
except RuntimeError as e :
|
187 |
if "device-side assert" in str(e):
|
188 |
# cannot do anything on cuda device side error, need tor estart
|
@@ -200,6 +200,17 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, voice_clea
|
|
200 |
else:
|
201 |
print("RuntimeError: non device-side assert error:", str(e))
|
202 |
raise e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
else:
|
204 |
gr.Warning("Please accept the Terms & Condition!")
|
205 |
return (
|
|
|
175 |
gpt_cond_latent,
|
176 |
speaker_embedding,)
|
177 |
try:
|
|
|
178 |
for i, chunk in enumerate(chunks):
|
179 |
+
wav_chunks.append(chunk)
|
180 |
print(f"Received chunk {i} of audio length {chunk.shape[-1]}")
|
181 |
out_file = f'{i}.wav'
|
182 |
write(out_file, 24000, chunk.detach().cpu().numpy().squeeze())
|
183 |
audio = AudioSegment.from_file(out_file)
|
184 |
audio.export(out_file, format='wav')
|
185 |
+
yield (None, out_file, None)
|
186 |
except RuntimeError as e :
|
187 |
if "device-side assert" in str(e):
|
188 |
# cannot do anything on cuda device side error, need tor estart
|
|
|
200 |
else:
|
201 |
print("RuntimeError: non device-side assert error:", str(e))
|
202 |
raise e
|
203 |
+
|
204 |
+
wav = torch.cat(wav_chunks, dim=0)
|
205 |
+
torchaudio.save("output.wav", wav.squeeze().unsqueeze(0).cpu(), 24000)
|
206 |
+
|
207 |
+
return (
|
208 |
+
gr.make_waveform(
|
209 |
+
audio="output.wav",
|
210 |
+
),
|
211 |
+
"output.wav",
|
212 |
+
speaker_wav,
|
213 |
+
)
|
214 |
else:
|
215 |
gr.Warning("Please accept the Terms & Condition!")
|
216 |
return (
|