Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from src.phonetics_mcp.phoneference import LANGUAGES, text_to_phonetics, phonetics_to_text | |
| # Create a list of tuples for the dropdown choices | |
| language_choices = list(LANGUAGES.items()) | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Phonetics MCP") | |
| with gr.Tab("Text to Phonetics"): | |
| with gr.Row(): | |
| text_input = gr.Textbox(label="Text") | |
| language_input_ttp = gr.Dropdown(choices=language_choices, label="Language") | |
| phonetics_output = gr.JSON(label="Phonetic Pronunciations") | |
| ttp_button = gr.Button("Convert to Phonetics") | |
| ttp_button.click( | |
| fn=text_to_phonetics, | |
| inputs=[text_input, language_input_ttp], | |
| outputs=phonetics_output, | |
| api_name="text_to_phonetics" | |
| ) | |
| with gr.Tab("Phonetics to Text"): | |
| with gr.Row(): | |
| ipa_input = gr.Textbox(label="IPA Expression") | |
| language_input_ptt = gr.Dropdown(choices=language_choices, label="Language") | |
| dictation_output = gr.JSON(label="Possible Dictations") | |
| ptt_button = gr.Button("Convert to Text") | |
| ptt_button.click( | |
| fn=phonetics_to_text, | |
| inputs=[ipa_input, language_input_ptt], | |
| outputs=dictation_output, | |
| api_name="phonetics_to_text" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860, mcp_server=True) | |