mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 18:23:59 +08:00
feat: 添加本地tts支援面板的"角色音色"
This commit is contained in:
+10
-3
@@ -66,6 +66,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
agent.getVadModelId(),
|
agent.getVadModelId(),
|
||||||
agent.getAsrModelId(),
|
agent.getAsrModelId(),
|
||||||
null,
|
null,
|
||||||
@@ -102,9 +103,11 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
}
|
}
|
||||||
// 获取音色信息
|
// 获取音色信息
|
||||||
String voice = null;
|
String voice = null;
|
||||||
|
String voiceRemark = null;
|
||||||
TimbreDetailsVO timbre = timbreService.get(agent.getTtsVoiceId());
|
TimbreDetailsVO timbre = timbreService.get(agent.getTtsVoiceId());
|
||||||
if (timbre != null) {
|
if (timbre != null) {
|
||||||
voice = timbre.getTtsVoice();
|
voice = timbre.getTtsVoice();
|
||||||
|
voiceRemark = timbre.getRemark();
|
||||||
}
|
}
|
||||||
// 构建返回数据
|
// 构建返回数据
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
@@ -138,6 +141,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
agent.getSystemPrompt(),
|
agent.getSystemPrompt(),
|
||||||
agent.getSummaryMemory(),
|
agent.getSummaryMemory(),
|
||||||
voice,
|
voice,
|
||||||
|
voiceRemark,
|
||||||
agent.getVadModelId(),
|
agent.getVadModelId(),
|
||||||
agent.getAsrModelId(),
|
agent.getAsrModelId(),
|
||||||
agent.getLlmModelId(),
|
agent.getLlmModelId(),
|
||||||
@@ -154,7 +158,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
/**
|
/**
|
||||||
* 构建配置信息
|
* 构建配置信息
|
||||||
*
|
*
|
||||||
* @param paramsList 系统参数列表
|
* @param config 系统参数列表
|
||||||
* @return 配置信息
|
* @return 配置信息
|
||||||
*/
|
*/
|
||||||
private Object buildConfig(Map<String, Object> config) {
|
private Object buildConfig(Map<String, Object> config) {
|
||||||
@@ -227,6 +231,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
*
|
*
|
||||||
* @param prompt 提示词
|
* @param prompt 提示词
|
||||||
* @param voice 音色
|
* @param voice 音色
|
||||||
|
* @param voiceRemark 備註
|
||||||
* @param vadModelId VAD模型ID
|
* @param vadModelId VAD模型ID
|
||||||
* @param asrModelId ASR模型ID
|
* @param asrModelId ASR模型ID
|
||||||
* @param llmModelId LLM模型ID
|
* @param llmModelId LLM模型ID
|
||||||
@@ -240,6 +245,7 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
String prompt,
|
String prompt,
|
||||||
String summaryMemory,
|
String summaryMemory,
|
||||||
String voice,
|
String voice,
|
||||||
|
String voiceRemark,
|
||||||
String vadModelId,
|
String vadModelId,
|
||||||
String asrModelId,
|
String asrModelId,
|
||||||
String llmModelId,
|
String llmModelId,
|
||||||
@@ -265,8 +271,9 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
if (model.getConfigJson() != null) {
|
if (model.getConfigJson() != null) {
|
||||||
typeConfig.put(model.getId(), model.getConfigJson());
|
typeConfig.put(model.getId(), model.getConfigJson());
|
||||||
// 如果是TTS类型,添加private_voice属性
|
// 如果是TTS类型,添加private_voice属性
|
||||||
if ("TTS".equals(modelTypes[i]) && voice != null) {
|
if ("TTS".equals(modelTypes[i])){
|
||||||
((Map<String, Object>) model.getConfigJson()).put("private_voice", voice);
|
if (voice != null) ((Map<String, Object>) model.getConfigJson()).put("private_voice", voice);
|
||||||
|
if (voiceRemark != null) ((Map<String, Object>) model.getConfigJson()).put("voice_remark", voiceRemark);
|
||||||
}
|
}
|
||||||
// 如果是Intent类型,且type=intent_llm,则给他添加附加模型
|
// 如果是Intent类型,且type=intent_llm,则给他添加附加模型
|
||||||
if ("Intent".equals(modelTypes[i])) {
|
if ("Intent".equals(modelTypes[i])) {
|
||||||
|
|||||||
@@ -129,6 +129,13 @@ class TTSProvider(TTSProviderBase):
|
|||||||
self.use_memory_cache = config.get("use_memory_cache", "on")
|
self.use_memory_cache = config.get("use_memory_cache", "on")
|
||||||
self.seed = int(config.get("seed")) if config.get("seed") else None
|
self.seed = int(config.get("seed")) if config.get("seed") else None
|
||||||
self.api_url = config.get("api_url", "http://127.0.0.1:8080/v1/tts")
|
self.api_url = config.get("api_url", "http://127.0.0.1:8080/v1/tts")
|
||||||
|
self.get_voice_data(config)
|
||||||
|
|
||||||
|
def get_voice_data(self, config: dict):
|
||||||
|
if not config.get('private_voice', '') and not config.get('voice_remark', ''):
|
||||||
|
return
|
||||||
|
self.reference_audio = config.get('private_voice')
|
||||||
|
self.reference_text = config.get('voice_remark')
|
||||||
|
|
||||||
async def text_to_speak(self, text, output_file):
|
async def text_to_speak(self, text, output_file):
|
||||||
# Prepare reference data
|
# Prepare reference data
|
||||||
|
|||||||
@@ -67,6 +67,14 @@ class TTSProvider(TTSProviderBase):
|
|||||||
)
|
)
|
||||||
self.audio_file_type = config.get("format", "wav")
|
self.audio_file_type = config.get("format", "wav")
|
||||||
|
|
||||||
|
self.get_voice_data(config)
|
||||||
|
|
||||||
|
def get_voice_data(self, config: dict):
|
||||||
|
if not config.get('private_voice', '') and not config.get('voice_remark', ''):
|
||||||
|
return
|
||||||
|
self.ref_audio_path = config.get('private_voice')
|
||||||
|
self.prompt_text = config.get('voice_remark')
|
||||||
|
|
||||||
async def text_to_speak(self, text, output_file):
|
async def text_to_speak(self, text, output_file):
|
||||||
request_json = {
|
request_json = {
|
||||||
"text": text,
|
"text": text,
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ class TTSProvider(TTSProviderBase):
|
|||||||
self.if_sr = str(config.get("if_sr", False)).lower() in ("true", "1", "yes")
|
self.if_sr = str(config.get("if_sr", False)).lower() in ("true", "1", "yes")
|
||||||
self.audio_file_type = config.get("format", "wav")
|
self.audio_file_type = config.get("format", "wav")
|
||||||
|
|
||||||
|
self.get_voice_data(config)
|
||||||
|
|
||||||
|
def get_voice_data(self, config: dict):
|
||||||
|
if not config.get('private_voice', '') and not config.get('voice_remark', ''):
|
||||||
|
return
|
||||||
|
self.refer_wav_path = config.get('private_voice')
|
||||||
|
self.prompt_text = config.get('voice_remark')
|
||||||
|
|
||||||
async def text_to_speak(self, text, output_file):
|
async def text_to_speak(self, text, output_file):
|
||||||
request_params = {
|
request_params = {
|
||||||
"refer_wav_path": self.refer_wav_path,
|
"refer_wav_path": self.refer_wav_path,
|
||||||
|
|||||||
Reference in New Issue
Block a user