changed to tacatron2
Browse files
app.py
CHANGED
@@ -41,12 +41,12 @@ def process_text(text):
|
|
41 |
return '\n'.join(processed)
|
42 |
|
43 |
def text_to_speech(text):
|
44 |
-
"""Convert text to speech using Hugging Face
|
45 |
try:
|
46 |
-
tts_pipeline = pipeline("text-to-speech", model="
|
47 |
output = tts_pipeline(text)
|
48 |
|
49 |
-
audio_array = np.array(output["
|
50 |
sample_rate = output["sampling_rate"]
|
51 |
|
52 |
audio_file = "output.wav"
|
|
|
41 |
return '\n'.join(processed)
|
42 |
|
43 |
def text_to_speech(text):
|
44 |
+
"""Convert text to speech using Hugging Face's SpeechBrain model."""
|
45 |
try:
|
46 |
+
tts_pipeline = pipeline("text-to-speech", model="speechbrain/tts-tacotron2-ljspeech", device=0 if torch.cuda.is_available() else -1)
|
47 |
output = tts_pipeline(text)
|
48 |
|
49 |
+
audio_array = np.array(output["audio"])
|
50 |
sample_rate = output["sampling_rate"]
|
51 |
|
52 |
audio_file = "output.wav"
|