homo-ge2pe / app.py
saeedzou's picture
Update app.py
fb53663 verified
raw
history blame contribute delete
548 Bytes
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
@app.get("/")
async def root():
return {"message": "Welcome to the Persian Phonemizer API. Use the /phonemize endpoint to process text."}
@app.post('/api/phonemize')
async def phonemize(req: PhonemizeRequest):
result = ge2pe.generate_with_punctuation(req.text, use_rules=True)
return {"phonemes": result}