mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
fix:修复语音无法找到新配置项output_file的bug
This commit is contained in:
parent
2861d59804
commit
a174a54633
7 changed files with 14 additions and 24 deletions
|
|
@ -30,7 +30,7 @@ log:
|
||||||
# 设置日志等级:INFO、DEBUG
|
# 设置日志等级:INFO、DEBUG
|
||||||
log_level: INFO
|
log_level: INFO
|
||||||
# 设置日志路径
|
# 设置日志路径
|
||||||
log_dir: log
|
log_dir: tmp
|
||||||
# 设置日志文件
|
# 设置日志文件
|
||||||
log_file: "server.log"
|
log_file: "server.log"
|
||||||
# 设置数据文件路径
|
# 设置数据文件路径
|
||||||
|
|
@ -397,7 +397,7 @@ TTS:
|
||||||
api_url: https://api.302ai.cn/doubao/tts_hd
|
api_url: https://api.302ai.cn/doubao/tts_hd
|
||||||
authorization: "Bearer "
|
authorization: "Bearer "
|
||||||
voice: "zh_female_wanwanxiaohe_moon_bigtts"
|
voice: "zh_female_wanwanxiaohe_moon_bigtts"
|
||||||
output_file: tmp/
|
output_dir: tmp/
|
||||||
access_token: "你的302API密钥"
|
access_token: "你的302API密钥"
|
||||||
ACGNTTS:
|
ACGNTTS:
|
||||||
#在线网址:https://acgn.ttson.cn/
|
#在线网址:https://acgn.ttson.cn/
|
||||||
|
|
|
||||||
|
|
@ -46,21 +46,13 @@ def get_config_file():
|
||||||
global default_config_file
|
global default_config_file
|
||||||
"""获取配置文件路径,优先使用私有配置文件(若存在)。
|
"""获取配置文件路径,优先使用私有配置文件(若存在)。
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: 配置文件路径(相对路径或默认路径)
|
str: 配置文件路径(相对路径或默认路径)
|
||||||
"""
|
"""
|
||||||
# 判断是否存在私有的配置文件
|
config_file = default_config_file
|
||||||
default_config = "config.yaml"
|
if os.path.exists(get_project_dir() + "data/." + default_config_file):
|
||||||
project_dir = get_project_dir()
|
config_file = "data/." + default_config_file
|
||||||
# 创建data目录(如果不存在)
|
return config_file
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
|
|
@ -118,7 +110,7 @@ def find_missing_keys(new_config, old_config, parent_key=''):
|
||||||
def check_config_file():
|
def check_config_file():
|
||||||
old_config_file = get_config_file()
|
old_config_file = get_config_file()
|
||||||
global default_config_file
|
global default_config_file
|
||||||
if not old_config_file.startswith('data'):
|
if not 'data' in old_config_file:
|
||||||
return
|
return
|
||||||
old_config = read_config(get_project_dir() + old_config_file)
|
old_config = read_config(get_project_dir() + old_config_file)
|
||||||
new_config = read_config(get_project_dir() + default_config_file)
|
new_config = read_config(get_project_dir() + default_config_file)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ logger = setup_logging()
|
||||||
class TTSProviderBase(ABC):
|
class TTSProviderBase(ABC):
|
||||||
def __init__(self, config, delete_audio_file):
|
def __init__(self, config, delete_audio_file):
|
||||||
self.delete_audio_file = 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
|
@abstractmethod
|
||||||
def generate_filename(self):
|
def generate_filename(self):
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class TTSProvider(TTSProviderBase):
|
||||||
self.headers = config.get("headers", {})
|
self.headers = config.get("headers", {})
|
||||||
self.params = config.get("params")
|
self.params = config.get("params")
|
||||||
self.format = config.get("format", "wav")
|
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):
|
def generate_filename(self):
|
||||||
return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}.{self.format}")
|
return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}.{self.format}")
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class TTSProvider(TTSProviderBase):
|
||||||
self.voice = config.get("voice", "alloy")
|
self.voice = config.get("voice", "alloy")
|
||||||
self.response_format = "wav"
|
self.response_format = "wav"
|
||||||
self.speed = config.get("speed", 1.0)
|
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)
|
check_model_key("TTS", self.api_key)
|
||||||
|
|
||||||
def generate_filename(self, extension=".wav"):
|
def generate_filename(self, extension=".wav"):
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class TTSProvider(TTSProviderBase):
|
||||||
self.volume_change_dB = config.get("volume_change_dB", 0)
|
self.volume_change_dB = config.get("volume_change_dB", 0)
|
||||||
self.speed_factor = config.get("speed_factor", 1)
|
self.speed_factor = config.get("speed_factor", 1)
|
||||||
self.stream = config.get("stream", False)
|
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.pitch_factor = config.get("pitch_factor", 0)
|
||||||
self.format = config.get("format", "mp3")
|
self.format = config.get("format", "mp3")
|
||||||
self.emotion = config.get("emotion", 1)
|
self.emotion = config.get("emotion", 1)
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,7 @@ services:
|
||||||
- ./data:/opt/xiaozhi-esp32-server/data
|
- ./data:/opt/xiaozhi-esp32-server/data
|
||||||
# 模型文件挂接,很重要
|
# 模型文件挂接,很重要
|
||||||
- ./models/SenseVoiceSmall/model.pt:/opt/xiaozhi-esp32-server/models/SenseVoiceSmall/model.pt
|
- ./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:
|
# xiaozhi-esp32-server-web:
|
||||||
# image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest
|
# image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue