fix: numpy数组转换为torch tensor

This commit is contained in:
2026-04-22 18:06:53 +08:00
parent 24b590d07f
commit 3ca2921820

View File

@@ -200,6 +200,11 @@ async def synthesize(
else:
audio_tensor = result
# 转换为 torch tensor如果是 numpy
import numpy as np
if isinstance(audio_tensor, np.ndarray):
audio_tensor = torch.from_numpy(audio_tensor).float()
# 确保 tensor 正确形状
if audio_tensor.dim() == 1:
audio_tensor = audio_tensor.unsqueeze(0)