Spaces:
Sleeping
Sleeping
SarahMarzouq
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -11,9 +11,8 @@ pipe_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ar-en")
|
|
11 |
|
12 |
# Initialize text-to-speech models for Arabic and English
|
13 |
# Arabic: text-to-speech
|
14 |
-
synthesiser_arabic = pipeline("text-to-speech", model="
|
15 |
-
|
16 |
-
speaker_embedding_arabic = torch.tensor(embeddings_dataset_arabic[105]["speaker_embeddings"]).unsqueeze(0)
|
17 |
|
18 |
# English: text-to-speech
|
19 |
synthesiser_english = pipeline("text-to-speech", model="microsoft/speecht5_tts")
|
@@ -48,10 +47,9 @@ def generate_poem_english(text):
|
|
48 |
clean_text = clean_text.replace("\\n", " ") # Replace newlines with a space
|
49 |
return clean_text
|
50 |
|
51 |
-
# Text-to-speech conversion for Arabic
|
52 |
def text_to_speech_arabic(text):
|
53 |
-
speech = synthesiser_arabic(text
|
54 |
-
audio_data = speech["audio"]
|
55 |
sampling_rate = speech["sampling_rate"]
|
56 |
return (sampling_rate, audio_data)
|
57 |
|
|
|
11 |
|
12 |
# Initialize text-to-speech models for Arabic and English
|
13 |
# Arabic: text-to-speech
|
14 |
+
synthesiser_arabic = synthesiser_arabic = pipeline("text-to-speech", model="facebook/mms-tts-ara")
|
15 |
+
|
|
|
16 |
|
17 |
# English: text-to-speech
|
18 |
synthesiser_english = pipeline("text-to-speech", model="microsoft/speecht5_tts")
|
|
|
47 |
clean_text = clean_text.replace("\\n", " ") # Replace newlines with a space
|
48 |
return clean_text
|
49 |
|
|
|
50 |
def text_to_speech_arabic(text):
|
51 |
+
speech = synthesiser_arabic(text)
|
52 |
+
audio_data = speech["audio"][0] # Flatten to 1D
|
53 |
sampling_rate = speech["sampling_rate"]
|
54 |
return (sampling_rate, audio_data)
|
55 |
|