mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 23:23:55 +08:00
兼容yaml配置和管理端配置
This commit is contained in:
@@ -15,10 +15,19 @@ class TTSProvider(TTSProviderBase):
|
||||
self.url = config.get("url")
|
||||
self.method = config.get("method", "GET")
|
||||
self.headers = config.get("headers", {})
|
||||
self.params = json.loads(config.get("params"))
|
||||
self.format = config.get("format", "wav")
|
||||
self.output_file = config.get("output_dir", "tmp/")
|
||||
|
||||
self.params = config.get("params")
|
||||
|
||||
if isinstance(self.params, str):
|
||||
try:
|
||||
self.params = json.loads(self.params)
|
||||
except json.JSONDecodeError:
|
||||
raise ValueError("Custom TTS配置参数出错,无法将字符串解析为对象")
|
||||
elif not isinstance(self.params, dict):
|
||||
raise TypeError("Custom TTS配置参数出错, 请参考配置说明")
|
||||
|
||||
def generate_filename(self):
|
||||
return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}.{self.format}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user