Enhance Gradio compatibility by adding theme handling and updating UI_CONFIG; refactor requirements.txt for clarity
Browse files- app.py +14 -2
- config.py +3 -1
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -15,7 +15,7 @@ import logging
|
|
| 15 |
import warnings
|
| 16 |
from tts_engine import tts_interface
|
| 17 |
from ui_utils import clear_all, load_example, create_tts_wrapper, create_system_status_display
|
| 18 |
-
from config import APP_TITLE, APP_DESCRIPTION, EXAMPLE_TEXTS, UI_CONFIG, UI_TEXT
|
| 19 |
|
| 20 |
# 设置日志
|
| 21 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -260,4 +260,16 @@ def create_interface():
|
|
| 260 |
# 启动应用
|
| 261 |
if __name__ == "__main__":
|
| 262 |
demo = create_interface()
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
import warnings
|
| 16 |
from tts_engine import tts_interface
|
| 17 |
from ui_utils import clear_all, load_example, create_tts_wrapper, create_system_status_display
|
| 18 |
+
from config import APP_TITLE, APP_DESCRIPTION, EXAMPLE_TEXTS, UI_CONFIG, UI_TEXT, GRADIO_THEME
|
| 19 |
|
| 20 |
# 设置日志
|
| 21 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 260 |
# 启动应用
|
| 261 |
if __name__ == "__main__":
|
| 262 |
demo = create_interface()
|
| 263 |
+
|
| 264 |
+
# 处理Gradio主题兼容性
|
| 265 |
+
launch_config = UI_CONFIG.copy()
|
| 266 |
+
try:
|
| 267 |
+
# 尝试使用主题参数(适用于较新版本的Gradio)
|
| 268 |
+
import gradio as gr
|
| 269 |
+
if hasattr(gr.Blocks, 'launch') and 'theme' in gr.Blocks.launch.__code__.co_varnames:
|
| 270 |
+
launch_config['theme'] = GRADIO_THEME
|
| 271 |
+
except:
|
| 272 |
+
# 如果出现错误,忽略主题设置
|
| 273 |
+
pass
|
| 274 |
+
|
| 275 |
+
demo.launch(**launch_config)
|
config.py
CHANGED
|
@@ -64,7 +64,6 @@ EXAMPLE_TEXTS = [
|
|
| 64 |
|
| 65 |
# UI配置
|
| 66 |
UI_CONFIG = {
|
| 67 |
-
"theme": "soft",
|
| 68 |
"server_name": "0.0.0.0",
|
| 69 |
"server_port": 7860,
|
| 70 |
"show_api": False,
|
|
@@ -72,6 +71,9 @@ UI_CONFIG = {
|
|
| 72 |
"quiet": False
|
| 73 |
}
|
| 74 |
|
|
|
|
|
|
|
|
|
|
| 75 |
# Gradio界面文本
|
| 76 |
UI_TEXT = {
|
| 77 |
"text_label": "🎯 输入日语文本",
|
|
|
|
| 64 |
|
| 65 |
# UI配置
|
| 66 |
UI_CONFIG = {
|
|
|
|
| 67 |
"server_name": "0.0.0.0",
|
| 68 |
"server_port": 7860,
|
| 69 |
"show_api": False,
|
|
|
|
| 71 |
"quiet": False
|
| 72 |
}
|
| 73 |
|
| 74 |
+
# Gradio主题配置(单独处理版本兼容性)
|
| 75 |
+
GRADIO_THEME = "soft"
|
| 76 |
+
|
| 77 |
# Gradio界面文本
|
| 78 |
UI_TEXT = {
|
| 79 |
"text_label": "🎯 输入日语文本",
|
requirements.txt
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# Hugging Face Spaces requirements for Genie TTS
|
| 2 |
# Based on official High-Logic/Genie Docker configuration
|
| 3 |
|
| 4 |
-
# Core web interface
|
| 5 |
-
gradio>=4.0.0
|
| 6 |
|
| 7 |
# ONNX Runtime for CPU inference (aligned with official)
|
| 8 |
onnxruntime>=1.16.0
|
|
|
|
| 1 |
# Hugging Face Spaces requirements for Genie TTS
|
| 2 |
# Based on official High-Logic/Genie Docker configuration
|
| 3 |
|
| 4 |
+
# Core web interface - specify compatible version range
|
| 5 |
+
gradio>=4.0.0,<5.0.0
|
| 6 |
|
| 7 |
# ONNX Runtime for CPU inference (aligned with official)
|
| 8 |
onnxruntime>=1.16.0
|