import gradio as gr import os from AinaTheme import theme from espeak_phonemizer import Phonemizer from dotenv import load_dotenv load_dotenv() MAX_INPUT_TEXT_LEN = int(os.environ.get("MAX_INPUT_TEXT_LEN", default=325)) #fonemitzador = Phonemizer("ca") def phonemiser(text, dialect): dialects = {"Central": "ca", "Valencian": "ca-va", "North-West": "ca-nw", "Balear": "ca-ba"} dialect = dialects[dialect] #Define dialect from espeak-ng-data/lang/roa/ca* fonemitzador = Phonemizer(dialect) #Set correct dialect for the phonemiser # synthesize fonemes = fonemitzador.phonemize(text, keep_clause_breakers=True) return fonemes title = "Comparativa de síntesi lliure en català️" description=""" Transcripció fonètica en català Transcipció fonètica per a diferents dialectes del català mitjançant eSpeak. Phonetic transcription for different dialects of Catalan using eSpeak. repo: https://github.com/projecte-aina/espeak-ng/tree/dev-ca """ def submit_input(input_, dialect): output = None if input_ is not None and len(input_) < MAX_INPUT_TEXT_LEN: output = phonemiser(input_, dialect) else: gr.Warning(f"Your text exceeds the {MAX_INPUT_TEXT_LEN}-character limit.") return output def change_interactive(text): input_state = text if input_state.strip() != "": return gr.update(interactive = True) else: return gr.update(interactive = False) def clean(): return ( None, None, ) with gr.Blocks(theme=theme) as app: gr.Markdown(f"