From 2e05ea96c507f332208455df323fb074973f6e51 Mon Sep 17 00:00:00 2001 From: Jacky He Date: Sat, 9 Aug 2025 13:55:49 +0800 Subject: [PATCH] fix: when text and word2ph is empty, get_bert_feature will not crash but return an empty tensor --- GPT_SoVITS/inference_webui.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GPT_SoVITS/inference_webui.py b/GPT_SoVITS/inference_webui.py index 046a2b15..42d03020 100644 --- a/GPT_SoVITS/inference_webui.py +++ b/GPT_SoVITS/inference_webui.py @@ -180,6 +180,8 @@ def get_bert_feature(text, word2ph): for i in range(len(word2ph)): repeat_feature = res[i].repeat(word2ph[i], 1) phone_level_feature.append(repeat_feature) + if len(phone_level_feature) == 0: + return torch.empty((res.shape[1], 0), dtype=res.dtype, device=res.device) phone_level_feature = torch.cat(phone_level_feature, dim=0) return phone_level_feature.T