Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ from TTS.utils.generic_utils import get_user_data_dir
|
|
9 |
|
10 |
import gradio as gr
|
11 |
from scipy.io.wavfile import write
|
|
|
12 |
|
13 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
14 |
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
|
@@ -40,11 +41,11 @@ def stream_audio(synthesis_text):
|
|
40 |
|
41 |
for i, chunk in enumerate(chunks):
|
42 |
print(f"Received chunk {i} of audio length {chunk.shape[-1]}")
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
yield
|
48 |
|
49 |
demo = gr.Interface(
|
50 |
fn=stream_audio,
|
|
|
9 |
|
10 |
import gradio as gr
|
11 |
from scipy.io.wavfile import write
|
12 |
+
from pydub import AudioSegment
|
13 |
|
14 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
15 |
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
|
|
|
41 |
|
42 |
for i, chunk in enumerate(chunks):
|
43 |
print(f"Received chunk {i} of audio length {chunk.shape[-1]}")
|
44 |
+
out_file = f'{i}.wav'
|
45 |
+
write(out_file, 24000, chunk.detach().cpu().numpy().squeeze())
|
46 |
+
audio = AudioSegment.from_file(out_file)
|
47 |
+
audio.export(out_file, format='wav')
|
48 |
+
yield out_file
|
49 |
|
50 |
demo = gr.Interface(
|
51 |
fn=stream_audio,
|