Spaces:
Build error
Build error
import gradio as gr | |
import phonetisaurus | |
from collections import namedtuple | |
model = phonetisaurus.Phonetisaurus(model="./model.fst") | |
def Phoneticize (args) : | |
results = model.Phoneticize ( | |
args["token"], | |
args["nbest"], | |
args["beam"], | |
args["thresh"], | |
args["write_fsts"], | |
args["accumulate"], | |
args["pmass"] | |
) | |
for result in results : | |
uniques = [model.FindOsym (u) for u in result.Uniques] | |
return "".join(uniques) | |
return "" | |
def phonemizer(text: str): | |
if not text: | |
return "" | |
args = { | |
"token": text, | |
"word": "word", | |
"nbest": 1, | |
"thresh": 10.0, | |
"write_fsts": False, | |
"accumulate": False, | |
"pmass": 0.0, | |
"beam": 500 | |
} | |
return f"/{Phoneticize(args)}/" | |
iface = gr.Interface( | |
title="Khmer Phonemizer", | |
description="Convert Khmer & English into Phonetic Symbols", | |
fn=phonemizer, inputs="text", | |
outputs="text", | |
allow_flagging="never", | |
) | |
iface.launch(show_api=False) | |