Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,6 @@ from huggingface_hub import login
|
|
24 |
from transformers.models.speecht5.number_normalizer import EnglishNumberNormalizer
|
25 |
from parler_tts import ParlerTTSForConditionalGeneration
|
26 |
from transformers import AutoTokenizer, AutoFeatureExtractor, set_seed
|
27 |
-
from string import punctuation
|
28 |
|
29 |
# Check if the token is already set in the environment variables
|
30 |
hf_token = os.getenv("HF_TOKEN")
|
@@ -503,9 +502,10 @@ def generate_audio_parler_tts(text):
|
|
503 |
generation = parler_model.generate(input_ids=inputs.input_ids, prompt_input_ids=prompt.input_ids)
|
504 |
audio_arr = generation.cpu().numpy().squeeze()
|
505 |
|
506 |
-
|
|
|
|
|
507 |
f.write(audio_arr.tobytes())
|
508 |
-
temp_audio_path = f.name
|
509 |
|
510 |
logging.debug(f"Audio saved to {temp_audio_path}")
|
511 |
return temp_audio_path
|
@@ -572,3 +572,4 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
572 |
|
573 |
demo.queue()
|
574 |
demo.launch(share=True)
|
|
|
|
24 |
from transformers.models.speecht5.number_normalizer import EnglishNumberNormalizer
|
25 |
from parler_tts import ParlerTTSForConditionalGeneration
|
26 |
from transformers import AutoTokenizer, AutoFeatureExtractor, set_seed
|
|
|
27 |
|
28 |
# Check if the token is already set in the environment variables
|
29 |
hf_token = os.getenv("HF_TOKEN")
|
|
|
502 |
generation = parler_model.generate(input_ids=inputs.input_ids, prompt_input_ids=prompt.input_ids)
|
503 |
audio_arr = generation.cpu().numpy().squeeze()
|
504 |
|
505 |
+
temp_audio_path = os.path.join(tempfile.gettempdir(), "parler_tts_audio.wav")
|
506 |
+
with open(temp_audio_path, "wb") as f:
|
507 |
+
f.write(parler_feature_extractor.sampling_rate.to_bytes(4, byteorder="little"))
|
508 |
f.write(audio_arr.tobytes())
|
|
|
509 |
|
510 |
logging.debug(f"Audio saved to {temp_audio_path}")
|
511 |
return temp_audio_path
|
|
|
572 |
|
573 |
demo.queue()
|
574 |
demo.launch(share=True)
|
575 |
+
|