fix: numpy数组转换为torch tensor
This commit is contained in:
@@ -200,6 +200,11 @@ async def synthesize(
|
|||||||
else:
|
else:
|
||||||
audio_tensor = result
|
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 正确形状
|
# 确保 tensor 正确形状
|
||||||
if audio_tensor.dim() == 1:
|
if audio_tensor.dim() == 1:
|
||||||
audio_tensor = audio_tensor.unsqueeze(0)
|
audio_tensor = audio_tensor.unsqueeze(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user