Skip to content

Commit

Permalink
Update: configure dynamic_loading for each model separately
Browse files Browse the repository at this point in the history
Revert the incorrect merge of lang_list in the refactor-config branch
  • Loading branch information
Artrajz committed Jan 5, 2025
1 parent 66ac048 commit 7943e2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions manager/TTSManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def process_ssml_infer_task(self, tasks, format):

def vits_infer(self, state, encode=True):
model = self.get_model(ModelType.VITS, state["id"])
if hasattr(config.vits_config, 'dynamic_loading') and config.vits_config.dynamic_loading:
if model.dynamic_loading:
model.load_model()
state["id"] = self.get_real_id(ModelType.VITS, state["id"]) # Change to real id
# 去除所有多余的空白字符
Expand Down Expand Up @@ -299,7 +299,7 @@ def vits_infer(self, state, encode=True):
audios.append(brk)

audio = np.concatenate(audios, axis=0)
if hasattr(config.vits_config, 'dynamic_loading') and config.vits_config.dynamic_loading:
if model.dynamic_loading:
model.release_model()
return self.encode(sampling_rate, audio, state["format"]) if encode else audio

Expand Down
13 changes: 5 additions & 8 deletions tts_app/voice_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,14 @@ def voice_vits_api():

# 校验模型是否支持输入的语言
speaker_lang = model_manager.voice_speakers[ModelType.VITS][id].get('lang')
if lang not in ["auto", "mix"] and len(speaker_lang) > 1 and lang not in speaker_lang:
logger.info(f"[{ModelType.VITS}] lang \"{lang}\" is not in {speaker_lang}")
return make_response(jsonify({"status": "error", "message": f"lang '{lang}' is not in {speaker_lang}"}),
400)
lang_list, status, msg = get_lang_list(lang, speaker_lang)
if status == "error":
return make_response(jsonify({"status": status, "message": msg}), 400)

# 如果配置文件中设置了LANGUAGE_AUTOMATIC_DETECT则强制将speaker_lang设置为LANGUAGE_AUTOMATIC_DETECT
# 如果配置文件中设置了LANGUAGE_AUTOMATIC_DETECT则强制将speaker_lang设置为LANGUAGE_AUTOMATIC_DETECT里的语言
if (lang_detect := config.language_identification.language_automatic_detect) and isinstance(lang_detect, list):
speaker_lang = lang_detect

lang_list = get_lang_list(lang, speaker_lang)

if use_streaming and format.upper() != "MP3":
format = "mp3"
logger.warning("Streaming response only supports MP3 format.")
Expand All @@ -188,7 +185,7 @@ def voice_vits_api():
"noise": noise,
"noisew": noisew,
"segment_size": segment_size,
"lang": lang_list[0],
"lang": lang_list,
"speaker_lang": speaker_lang,
}

Expand Down

0 comments on commit 7943e2f

Please sign in to comment.