liumaolin
commited on
Commit
·
ee4663a
1
Parent(s):
3b73d5e
Refactor `audio_generator/manager.py`: streamline imports, remove redundant modules in `register_all_tts`, and adjust dynamic import spec for improved maintainability.
Browse files
src/VoiceDialogue/services/audio/audio_generator/manager.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
-
import
|
| 2 |
import inspect
|
| 3 |
-
|
| 4 |
import re
|
| 5 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from .runtime.interface import TTSInterface
|
| 7 |
-
from .models.base import BaseTTSConfig, TTSConfigType
|
| 8 |
|
| 9 |
|
| 10 |
@dataclass
|
|
@@ -140,10 +143,7 @@ tts_manager = TTSManager()
|
|
| 140 |
|
| 141 |
def register_all_tts():
|
| 142 |
"""自动发现并注册runtime目录中的所有TTS实现"""
|
| 143 |
-
|
| 144 |
-
import importlib
|
| 145 |
-
from pathlib import Path
|
| 146 |
-
|
| 147 |
# 获取runtime目录路径
|
| 148 |
runtime_dir = Path(__file__).parent / "runtime"
|
| 149 |
|
|
@@ -155,7 +155,7 @@ def register_all_tts():
|
|
| 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)
|
|
|
|
| 1 |
+
import importlib.util
|
| 2 |
import inspect
|
| 3 |
+
import logging
|
| 4 |
import re
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Dict, Type
|
| 8 |
+
|
| 9 |
+
from .models.base import BaseTTSConfig
|
| 10 |
from .runtime.interface import TTSInterface
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
@dataclass
|
|
|
|
| 143 |
|
| 144 |
def register_all_tts():
|
| 145 |
"""自动发现并注册runtime目录中的所有TTS实现"""
|
| 146 |
+
|
|
|
|
|
|
|
|
|
|
| 147 |
# 获取runtime目录路径
|
| 148 |
runtime_dir = Path(__file__).parent / "runtime"
|
| 149 |
|
|
|
|
| 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)
|