Download app.py from muaadh019/mo: direct link, hf CLI and curl.
- Browser
- Download file 849 Bytes
-
https://huggingface.co/spaces/muaadh019/mo/resolve/main/app.py
- Command line
-
hf download hf://spaces/muaadh019/mo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/muaadh019/mo/resolve/main/app.py
849 Bytes
| from fastapi import FastAPI | |
| from fastapi.responses import FileResponse | |
| from TTS.api import TTS | |
| import uuid | |
| import os | |
| app = FastAPI() | |
| # ุชุญู ูู ู ูุฏูู XTTS | |
| tts = TTS( | |
| model_name="tts_models/multilingual/multi-dataset/xtts_v2", | |
| progress_bar=False, | |
| gpu=False | |
| ) | |
| OUTPUT_DIR = "outputs" | |
| os.makedirs(OUTPUT_DIR, exist_ok=True) | |
| def home(): | |
| return { | |
| "message": "Saudi Arabic TTS is running ๐๏ธ๐ธ๐ฆ", | |
| "usage": "/tts?text=ููุง+ูุงููู" | |
| } | |
| def text_to_speech(text: str): | |
| filename = f"{uuid.uuid4()}.wav" | |
| filepath = os.path.join(OUTPUT_DIR, filename) | |
| tts.tts_to_file( | |
| text=text, | |
| file_path=filepath, | |
| language="ar" | |
| ) | |
| return FileResponse( | |
| filepath, | |
| media_type="audio/wav", | |
| filename="saudi_tts.wav" | |
| ) | |