Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
8ddffb7
1
Parent(s):
e9fd913
chore: Update app.py and requirements.txt
Browse files- app.py +10 -10
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
import tempfile
|
| 2 |
|
| 3 |
-
import requests
|
| 4 |
import edge_tts
|
| 5 |
import gradio as gr
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
language_dict = {
|
| 10 |
"English": {
|
|
@@ -443,20 +442,21 @@ language_dict = {
|
|
| 443 |
}
|
| 444 |
}
|
| 445 |
|
|
|
|
|
|
|
| 446 |
async def text_to_speech_edge(text, language_code, speaker, tashkeel_checkbox=False):
|
| 447 |
|
|
|
|
| 448 |
if language_code == "Arabic" and tashkeel_checkbox:
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
text = response.text.strip()
|
| 453 |
voice = language_dict[language_code][speaker]
|
| 454 |
communicate = edge_tts.Communicate(text, voice)
|
| 455 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
| 456 |
-
|
| 457 |
-
|
| 458 |
|
| 459 |
-
print(tmp_path)
|
| 460 |
return text, tmp_path
|
| 461 |
|
| 462 |
|
|
|
|
| 1 |
import tempfile
|
| 2 |
|
|
|
|
| 3 |
import edge_tts
|
| 4 |
import gradio as gr
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
import pyarabic.araby as araby
|
| 7 |
|
| 8 |
language_dict = {
|
| 9 |
"English": {
|
|
|
|
| 442 |
}
|
| 443 |
}
|
| 444 |
|
| 445 |
+
pipe = pipeline("text2text-generation", model="mush42/fine-tashkeel")
|
| 446 |
+
|
| 447 |
async def text_to_speech_edge(text, language_code, speaker, tashkeel_checkbox=False):
|
| 448 |
|
| 449 |
+
# Remove diacritics from Arabic text then add tashkeel
|
| 450 |
if language_code == "Arabic" and tashkeel_checkbox:
|
| 451 |
+
text = pipe(araby.strip_diacritics(text))[0]["generated_text"].strip()
|
| 452 |
+
|
| 453 |
+
# Get the voice for the selected language and speaker
|
|
|
|
| 454 |
voice = language_dict[language_code][speaker]
|
| 455 |
communicate = edge_tts.Communicate(text, voice)
|
| 456 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
| 457 |
+
tmp_path = tmp_file.name
|
| 458 |
+
await communicate.save(tmp_path)
|
| 459 |
|
|
|
|
| 460 |
return text, tmp_path
|
| 461 |
|
| 462 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
gradio
|
| 2 |
edge-tts
|
| 3 |
-
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
edge-tts
|
| 3 |
+
transformers
|
| 4 |
+
pyarabic
|