Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from GE2PE import GE2PE | |
| import uvicorn | |
| app = FastAPI() | |
| ge2pe = GE2PE(model_path='./homo-ge2pe', GPU=False) | |
| class PhonemizeRequest(BaseModel): | |
| text: str | |
| # Route | |
| async def root(): | |
| return {"message": "Welcome to the Persian Phonemizer API. Use the /phonemize endpoint to process text."} | |
| async def phonemize(req: PhonemizeRequest): | |
| result = ge2pe.generate_with_punctuation(req.text, use_rules=True) | |
| return {"phonemes": result} | |