liumaolin
commited on
Commit
·
9bfcd24
1
Parent(s):
cf355e6
Refactor TTS module loading in `audio_generator/manager.py`: replace `importlib.import_module` with `importlib.util` for improved dynamic import handling and error logging.
Browse files
src/VoiceDialogue/services/audio/audio_generator/manager.py
CHANGED
|
@@ -154,9 +154,12 @@ def register_all_tts():
|
|
| 154 |
|
| 155 |
module_name = py_file.stem
|
| 156 |
try:
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
| 160 |
logging.info(f"Successfully imported TTS module: {module_name}")
|
| 161 |
except ImportError as e:
|
| 162 |
logging.warning(f"Failed to import TTS module {module_name}: {e}")
|
|
|
|
| 154 |
|
| 155 |
module_name = py_file.stem
|
| 156 |
try:
|
| 157 |
+
spec = importlib.util.spec_from_file_location(
|
| 158 |
+
f"runtime.{module_name}",
|
| 159 |
+
py_file
|
| 160 |
+
)
|
| 161 |
+
module = importlib.util.module_from_spec(spec)
|
| 162 |
+
spec.loader.exec_module(module)
|
| 163 |
logging.info(f"Successfully imported TTS module: {module_name}")
|
| 164 |
except ImportError as e:
|
| 165 |
logging.warning(f"Failed to import TTS module {module_name}: {e}")
|