refactor: remove redundant condition and rename shadowed waveform variable

This commit is contained in:
2026-04-05 10:41:08 +02:00
parent 0760e60373
commit b273f8f2d7
+3 -3
View File
@@ -38,13 +38,13 @@ class OmniVoiceGenerate:
if mode == "voice_design" and not instruct: if mode == "voice_design" and not instruct:
raise ValueError("voice_design mode requires an instruct string (e.g. 'female, low pitch')") raise ValueError("voice_design mode requires an instruct string (e.g. 'female, low pitch')")
if mode == "voice_cloning" and ref_audio is not None: if mode == "voice_cloning":
tmp = tempfile.NamedTemporaryFile(suffix=".wav", delete=False) tmp = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
tmp_path = tmp.name tmp_path = tmp.name
tmp.close() tmp.close()
try: try:
waveform = ref_audio["waveform"].squeeze(0).cpu() # (channels, samples) ref_waveform = ref_audio["waveform"].squeeze(0).cpu() # (channels, samples)
torchaudio.save(tmp_path, waveform, int(ref_audio["sample_rate"])) torchaudio.save(tmp_path, ref_waveform, int(ref_audio["sample_rate"]))
kwargs["ref_audio"] = tmp_path kwargs["ref_audio"] = tmp_path
if ref_text: if ref_text:
kwargs["ref_text"] = ref_text kwargs["ref_text"] = ref_text