mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 17:43:55 +08:00
Merge pull request #1534 from xinnan-tech/py_wakeup_Unicode_fix
解决GBK编码保存问题;音频格式修改
This commit is contained in:
@@ -11,8 +11,8 @@ class TTSProvider(TTSProviderBase):
|
|||||||
self.voice = config.get("private_voice")
|
self.voice = config.get("private_voice")
|
||||||
else:
|
else:
|
||||||
self.voice = config.get("voice")
|
self.voice = config.get("voice")
|
||||||
self.response_format = config.get("response_format", "mp3")
|
self.response_format = config.get("response_format", "wav")
|
||||||
self.audio_file_type = config.get("response_format", "mp3")
|
self.audio_file_type = config.get("response_format", "wav")
|
||||||
self.host = "api.coze.cn"
|
self.host = "api.coze.cn"
|
||||||
self.api_url = f"https://{self.host}/v1/audio/speech"
|
self.api_url = f"https://{self.host}/v1/audio/speech"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import yaml
|
import yaml
|
||||||
import time
|
import time
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -108,13 +109,16 @@ class WakeupWordsConfig:
|
|||||||
def update_wakeup_response(self, voice: str, file_path: str, text: str):
|
def update_wakeup_response(self, voice: str, file_path: str, text: str):
|
||||||
"""更新唤醒词回复配置"""
|
"""更新唤醒词回复配置"""
|
||||||
try:
|
try:
|
||||||
|
# 过滤表情字符
|
||||||
|
filtered_text = re.sub(r'[\U0001F600-\U0001F64F]', '', text)
|
||||||
|
|
||||||
config = self._load_config()
|
config = self._load_config()
|
||||||
voice_hash = hashlib.md5(voice.encode()).hexdigest()
|
voice_hash = hashlib.md5(voice.encode()).hexdigest()
|
||||||
config[voice_hash] = {
|
config[voice_hash] = {
|
||||||
"voice": voice,
|
"voice": voice,
|
||||||
"file_path": file_path,
|
"file_path": file_path,
|
||||||
"time": time.time(),
|
"time": time.time(),
|
||||||
"text": text,
|
"text": filtered_text,
|
||||||
}
|
}
|
||||||
self._save_config(config)
|
self._save_config(config)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user