fix:修复语音无法找到新配置项output_file的bug

This commit is contained in:
hrz 2025-03-18 12:38:09 +08:00
parent 2861d59804
commit a174a54633
7 changed files with 14 additions and 24 deletions

View file

@ -30,7 +30,7 @@ log:
# 设置日志等级:INFO、DEBUG
log_level: INFO
# 设置日志路径
log_dir: log
log_dir: tmp
# 设置日志文件
log_file: "server.log"
# 设置数据文件路径
@ -397,7 +397,7 @@ TTS:
api_url: https://api.302ai.cn/doubao/tts_hd
authorization: "Bearer "
voice: "zh_female_wanwanxiaohe_moon_bigtts"
output_file: tmp/
output_dir: tmp/
access_token: "你的302API密钥"
ACGNTTS:
#在线网址:https://acgn.ttson.cn/

View file

@ -46,21 +46,13 @@ def get_config_file():
global default_config_file
"""获取配置文件路径,优先使用私有配置文件(若存在)。
Returns:
Returns:
str: 配置文件路径(相对路径或默认路径)
"""
# 判断是否存在私有的配置文件
default_config = "config.yaml"
project_dir = get_project_dir()
# 创建data目录(如果不存在)
data_dir = os.path.join(project_dir, "data")
os.makedirs(data_dir, exist_ok=True)
# 配置文件路径
config_path = os.path.join(project_dir, "data", default_config)
# 优先使用私有配置,若不存在则使用默认配置
config_path = config_path if os.path.exists(config_path) else default_config
return config_path
"""
config_file = default_config_file
if os.path.exists(get_project_dir() + "data/." + default_config_file):
config_file = "data/." + default_config_file
return config_file
def load_config():
@ -118,7 +110,7 @@ def find_missing_keys(new_config, old_config, parent_key=''):
def check_config_file():
old_config_file = get_config_file()
global default_config_file
if not old_config_file.startswith('data'):
if not 'data' in old_config_file:
return
old_config = read_config(get_project_dir() + old_config_file)
new_config = read_config(get_project_dir() + default_config_file)

View file

@ -13,7 +13,7 @@ logger = setup_logging()
class TTSProviderBase(ABC):
def __init__(self, config, delete_audio_file):
self.delete_audio_file = delete_audio_file
self.output_file = config.get("output_file")
self.output_file = config.get("output_dir")
@abstractmethod
def generate_filename(self):

View file

@ -15,7 +15,7 @@ class TTSProvider(TTSProviderBase):
self.headers = config.get("headers", {})
self.params = config.get("params")
self.format = config.get("format", "wav")
self.output_file = config.get("output_file", "tmp/")
self.output_file = config.get("output_dir", "tmp/")
def generate_filename(self):
return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}.{self.format}")

View file

@ -14,7 +14,7 @@ class TTSProvider(TTSProviderBase):
self.voice = config.get("voice", "alloy")
self.response_format = "wav"
self.speed = config.get("speed", 1.0)
self.output_file = config.get("output_file", "tmp/")
self.output_file = config.get("output_dir", "tmp/")
check_model_key("TTS", self.api_key)
def generate_filename(self, extension=".wav"):

View file

@ -17,7 +17,7 @@ class TTSProvider(TTSProviderBase):
self.volume_change_dB = config.get("volume_change_dB", 0)
self.speed_factor = config.get("speed_factor", 1)
self.stream = config.get("stream", False)
self.output_file = config.get("output_file")
self.output_file = config.get("output_dir")
self.pitch_factor = config.get("pitch_factor", 0)
self.format = config.get("format", "mp3")
self.emotion = config.get("emotion", 1)

View file

@ -21,9 +21,7 @@ services:
- ./data:/opt/xiaozhi-esp32-server/data
# 模型文件挂接,很重要
- ./models/SenseVoiceSmall/model.pt:/opt/xiaozhi-esp32-server/models/SenseVoiceSmall/model.pt
# tmp目录挂接,TTS和ASR的output_dir路径默认配置挂载,
# 若要映射本地目录,请修改config.yaml中的output_dir路径,key和value在此配置后面赋值增加即可
- ./tmp:/opt/xiaozhi-esp32-server/tmp
# #智控台还没开发好,还不能完全使用,会报很多错误,如果是非技术人员,请不要启用智控台服务
# xiaozhi-esp32-server-web:
# image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest