mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-09-29 17:10:02 +08:00
fixed resample audio and tested in full run
This commit is contained in:
parent
da5aa78224
commit
1cdd41d877
@ -51,14 +51,13 @@ def resample_audio(audio: torch.Tensor, orig_sr: int, target_sr: int) -> torch.T
|
|||||||
audio = audio.unsqueeze(0)
|
audio = audio.unsqueeze(0)
|
||||||
# audio shape: (batch, channels, samples)
|
# audio shape: (batch, channels, samples)
|
||||||
batch, channels, samples = audio.shape
|
batch, channels, samples = audio.shape
|
||||||
new_samples = int(samples * target_sr / orig_sr)
|
# Reshape to combine batch and channels for interpolation
|
||||||
audio = audio.view(batch * channels, 1, samples)
|
audio = audio.reshape(batch * channels, 1, samples)
|
||||||
resampled = F.interpolate(audio, size=new_samples, mode='linear', align_corners=False)
|
# Use scale_factor instead of a computed size for ONNX export compatibility
|
||||||
resampled = resampled.view(batch, channels, new_samples)
|
resampled = F.interpolate(audio, scale_factor=target_sr / orig_sr, mode='linear', align_corners=False)
|
||||||
if resampled.shape[0] == 1 and resampled.shape[1] == 1:
|
new_samples = resampled.shape[-1]
|
||||||
resampled = resampled.squeeze(0).squeeze(0)
|
resampled = resampled.reshape(batch, channels, new_samples)
|
||||||
elif resampled.shape[0] == 1:
|
resampled = resampled.squeeze(0).squeeze(0)
|
||||||
resampled = resampled.squeeze(0)
|
|
||||||
return resampled
|
return resampled
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import torch
|
|||||||
from TTS_infer_pack.TextPreprocessor_onnx import TextPreprocessorOnnx
|
from TTS_infer_pack.TextPreprocessor_onnx import TextPreprocessorOnnx
|
||||||
|
|
||||||
|
|
||||||
MODEL_PATH = "playground/v2pro_export/v2pro"
|
MODEL_PATH = "onnx/v2pro_export/v2pro"
|
||||||
|
|
||||||
def audio_postprocess(
|
def audio_postprocess(
|
||||||
audios,
|
audios,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user