"""otto 活字印刷 —— 业务逻辑(Service 层)。""" from __future__ import annotations import asyncio import os from pathlib import Path from ..res.HuoZiYinShua.huoZiYinShua import huoZiYinShua _PLUGIN_ROOT = Path(__file__).resolve().parents[1] _settings = { "sourceDirectory": str(_PLUGIN_ROOT / "res" / "HuoZiYinShua" / "sources") + os.sep, "ysddSourceDirectory": str(_PLUGIN_ROOT / "res" / "HuoZiYinShua" / "ysddSources") + os.sep, "dictFile": str(_PLUGIN_ROOT / "res" / "HuoZiYinShua" / "dictionary.json"), "ysddTableFile": str(_PLUGIN_ROOT / "res" / "HuoZiYinShua" / "ysddTable.json"), } _HZYS = huoZiYinShua(_settings) async def synthesize(txt: str, reverse: bool) -> bytes: """合成 otto 语音,返回 base64(原声大碟模式);同步调用放入线程避免阻塞事件循环。""" return await asyncio.to_thread( _HZYS.export, txt, True, 1, 1, False, reverse )