Spaces:
Build error
Build error
File size: 1,111 Bytes
be5a86d ef9896a 6b4d109 ef9896a be5a86d ef9896a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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()
|