Spaces:
Runtime error
Runtime error
Update TTS/tts.py
Browse files- TTS/tts.py +12 -11
TTS/tts.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
-
from
|
| 2 |
-
import torch
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
def text_to_speech(text):
|
| 9 |
-
inputs = tokenizer(text, return_tensors="pt")
|
| 10 |
-
with torch.no_grad():
|
| 11 |
-
output = model(**inputs)
|
| 12 |
-
waveform = output.waveform.squeeze().numpy()
|
| 13 |
-
sampling_rate = model.config.sampling_rate
|
| 14 |
-
return waveform, sampling_rate
|
|
|
|
| 1 |
+
from TTS.api import TTS
|
|
|
|
| 2 |
|
| 3 |
+
# تحميل موديل XTTS
|
| 4 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)
|
| 5 |
|
| 6 |
+
def generate_voice(text, speaker_wav_path, language="ar"):
|
| 7 |
+
output_path = "output.wav"
|
| 8 |
+
tts.tts_to_file(
|
| 9 |
+
text=text,
|
| 10 |
+
file_path=output_path,
|
| 11 |
+
speaker_wav=speaker_wav_path,
|
| 12 |
+
language=language
|
| 13 |
+
)
|
| 14 |
+
return output_path
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|