Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import torch
|
|
3 |
from transformers.models.speecht5.number_normalizer import EnglishNumberNormalizer
|
4 |
from string import punctuation
|
5 |
import re
|
|
|
6 |
|
7 |
from parler_tts import ParlerTTSForConditionalGeneration
|
8 |
from transformers import AutoTokenizer, AutoFeatureExtractor, set_seed
|
@@ -62,9 +63,10 @@ def gen_tts(text, description):
|
|
62 |
temperature=1.0,
|
63 |
)
|
64 |
audio_arr = generation.cpu().numpy().squeeze()
|
65 |
-
return SAMPLE_RATE, audio_arr
|
66 |
except Exception as e:
|
67 |
-
|
|
|
68 |
|
69 |
# Gradio interface
|
70 |
with gr.Blocks() as block:
|
@@ -83,7 +85,7 @@ with gr.Blocks() as block:
|
|
83 |
audio_out = gr.Audio(label="Parler-TTS generation", type="numpy", elem_id="audio_out")
|
84 |
|
85 |
inputs = [input_text, description]
|
86 |
-
outputs =
|
87 |
run_button.click(fn=gen_tts, inputs=inputs, outputs=outputs, queue=True)
|
88 |
|
89 |
# Launch the interface
|
|
|
3 |
from transformers.models.speecht5.number_normalizer import EnglishNumberNormalizer
|
4 |
from string import punctuation
|
5 |
import re
|
6 |
+
import numpy as np # Ensure NumPy is imported for audio data processing
|
7 |
|
8 |
from parler_tts import ParlerTTSForConditionalGeneration
|
9 |
from transformers import AutoTokenizer, AutoFeatureExtractor, set_seed
|
|
|
63 |
temperature=1.0,
|
64 |
)
|
65 |
audio_arr = generation.cpu().numpy().squeeze()
|
66 |
+
return SAMPLE_RATE, audio_arr # Return sample rate and audio array
|
67 |
except Exception as e:
|
68 |
+
print(f"Error in TTS generation: {str(e)}")
|
69 |
+
return SAMPLE_RATE, np.zeros((SAMPLE_RATE,)) # Return silence in case of error
|
70 |
|
71 |
# Gradio interface
|
72 |
with gr.Blocks() as block:
|
|
|
85 |
audio_out = gr.Audio(label="Parler-TTS generation", type="numpy", elem_id="audio_out")
|
86 |
|
87 |
inputs = [input_text, description]
|
88 |
+
outputs = audio_out # Only output the audio component
|
89 |
run_button.click(fn=gen_tts, inputs=inputs, outputs=outputs, queue=True)
|
90 |
|
91 |
# Launch the interface
|