[Bugfix] Fix Fish Speech voice clone FileNotFoundError on multi-GPU (#2606)

Signed-off-by: Sy03 <1370724210@qq.com>
This commit is contained in:
Sy03 authored and GitHub committed 2026-04-09 20:34:34 +00:00
1 parent 85d63c47f9
commit 694be6f2e1
5 files changed
+14 -28

No files matched your search

@@ -14,7 +14,6 @@ from __future__ import annotations
import dataclasses
import math
import os
from collections.abc import Iterable
from typing import Any
@@ -518,17 +517,19 @@ class FishSpeechSlowARForConditionalGeneration(nn.Module):
tokenizer = self._get_tokenizer()
ref_text = info_dict.get("ref_text")
text = info_dict.get("text")
ref_audio_path = info_dict.get("ref_audio_path")
ref_audio_sr = info_dict.get("ref_audio_sr")
if not isinstance(ref_text, str) or not isinstance(text, str):
raise ValueError("Fish Speech structured voice clone requires string text and ref_text")
if not isinstance(ref_audio_path, str) or not ref_audio_path:
raise ValueError("Fish Speech structured voice clone requires ref_audio_path")
if not isinstance(ref_audio_sr, int):
raise ValueError("Fish Speech structured voice clone requires integer ref_audio_sr")
ref_audio_wav = np.load(ref_audio_path)
os.remove(ref_audio_path)
ref_audio_wav_raw = info_dict.get("ref_audio_wav")
if ref_audio_wav_raw is None:
raise ValueError("Fish Speech structured voice clone requires ref_audio_wav")
if isinstance(ref_audio_wav_raw, torch.Tensor):
ref_audio_wav = ref_audio_wav_raw.cpu().numpy()
else:
ref_audio_wav = np.asarray(ref_audio_wav_raw, dtype=np.float32)
ref_codes_fq = encode_reference_audio_codes(
self.model_path,