liumaolin
commited on
Commit
·
6f036c6
1
Parent(s):
ad7bf8d
Refactor `__init__.py` in TTS runtime: streamline `__all__` handling, improve logging for import failures, and enhance maintainability of module exports.
Browse files
src/VoiceDialogue/services/audio/generators/runtime/__init__.py
CHANGED
|
@@ -9,26 +9,28 @@ TTS运行时模块,包含:
|
|
| 9 |
|
| 10 |
from .interface import TTSInterface, TTSFactory
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# 导入所有TTS实现,确保注册装饰器被执行
|
| 13 |
try:
|
| 14 |
from .moyoyo import MoYoYoTTS
|
| 15 |
-
from .kokoro import KokoroTTS
|
| 16 |
|
| 17 |
-
__all__
|
| 18 |
-
'TTSInterface',
|
| 19 |
-
'TTSFactory',
|
| 20 |
-
'MoYoYoTTS',
|
| 21 |
-
'KokoroTTS'
|
| 22 |
-
]
|
| 23 |
except ImportError as e:
|
| 24 |
# 如果某些TTS实现无法导入,不影响整体功能
|
| 25 |
import logging
|
| 26 |
|
| 27 |
logging.warning(f"Failed to import some TTS implementations: {e}")
|
| 28 |
-
__all__ = [
|
| 29 |
-
'TTSInterface',
|
| 30 |
-
'TTSFactory'
|
| 31 |
-
]
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
from .interface import TTSInterface, TTSFactory
|
| 11 |
|
| 12 |
+
__all__ = [
|
| 13 |
+
'TTSInterface',
|
| 14 |
+
'TTSFactory',
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
# 导入所有TTS实现,确保注册装饰器被执行
|
| 18 |
try:
|
| 19 |
from .moyoyo import MoYoYoTTS
|
|
|
|
| 20 |
|
| 21 |
+
__all__.append('MoYoYoTTS')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
except ImportError as e:
|
| 23 |
# 如果某些TTS实现无法导入,不影响整体功能
|
| 24 |
import logging
|
| 25 |
|
| 26 |
logging.warning(f"Failed to import some TTS implementations: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
try:
|
| 29 |
+
from .kokoro import KokoroTTS
|
| 30 |
+
|
| 31 |
+
__all__.append('KokoroTTS')
|
| 32 |
+
except ImportError as e:
|
| 33 |
+
# 如果某些TTS实现无法导入,不影响整体功能
|
| 34 |
+
import logging
|
| 35 |
+
|
| 36 |
+
logging.warning(f"Failed to import some TTS implementations: {e}")
|