Spaces:
Build error
Build error
| import gradio as gr | |
| import subprocess | |
| import sys | |
| import os | |
| import shutil | |
| # Попытка установить pexpect через pip (лучше делать заранее) | |
| try: | |
| import pexpect | |
| except ImportError: | |
| subprocess.check_call([sys.executable, "-m", "pip", "install", "pexpect"]) | |
| def espeak_to_ipa(text, lang="en"): | |
| # Проверяем, установлен ли espeak-ng | |
| if not shutil.which("espeak-ng"): | |
| return "Error: espeak-ng is not installed. Please install it with sudo apt install espeak-ng" | |
| cmd = ["espeak-ng", "-v", lang, "--ipa=3", "-q", text] | |
| result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| return result.stdout.decode("utf-8").strip() | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| def text_to_ipa(text): | |
| return espeak_to_ipa(text) | |
| demo = gr.Interface(fn=text_to_ipa, inputs="text", outputs="text", | |
| title="Text to IPA with espeak-ng", | |
| description="Введите текст, и получите IPA транскрипцию через espeak-ng") | |
| demo.launch() | |