Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from llama_cpp import Llama
|
|
3 |
import os
|
4 |
from groq import Groq
|
5 |
import numpy as np
|
6 |
-
|
7 |
|
8 |
#tts
|
9 |
from balacoon_tts import TTS
|
@@ -47,10 +47,11 @@ llm = Llama.from_pretrained(
|
|
47 |
def text_to_speech(text):
|
48 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as temp_file:
|
49 |
with locker:
|
50 |
-
|
51 |
-
audio_data_int16 = (audio_data * 32767).astype(np.int16)
|
52 |
output_file = temp_file.name
|
53 |
-
|
|
|
|
|
54 |
return output_file
|
55 |
|
56 |
|
|
|
3 |
import os
|
4 |
from groq import Groq
|
5 |
import numpy as np
|
6 |
+
import wave
|
7 |
|
8 |
#tts
|
9 |
from balacoon_tts import TTS
|
|
|
47 |
def text_to_speech(text):
|
48 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as temp_file:
|
49 |
with locker:
|
50 |
+
samples = tts.synthesize(text, "92")
|
|
|
51 |
output_file = temp_file.name
|
52 |
+
with wave.open(f"{output_file}", "w") as fp:
|
53 |
+
fp.setparams((1, 2, tts.get_sampling_rate(), len(samples), "NONE", "NONE"))
|
54 |
+
fp.writeframes(samples)
|
55 |
return output_file
|
56 |
|
57 |
|