✨ | Added app.py script so the model can be used.
This commit is contained in:
@@ -50,3 +50,22 @@ def split_audio(audio_tensor: torch.Tensor, chunk_size: int = 128) -> list[torch
|
||||
chunks = list(torch.split(audio_tensor, chunk_size, dim=split_dim))
|
||||
|
||||
return chunks
|
||||
|
||||
def reconstruct_audio(chunks: list[torch.Tensor]) -> torch.Tensor:
|
||||
if not chunks:
|
||||
return torch.empty(0)
|
||||
|
||||
if len(chunks) == 1 and chunks[0].dim() == 0:
|
||||
return chunks[0]
|
||||
|
||||
concat_dim = -1
|
||||
|
||||
try:
|
||||
reconstructed_tensor = torch.cat(chunks, dim=concat_dim)
|
||||
except RuntimeError as e:
|
||||
raise RuntimeError(
|
||||
f"Failed to concatenate audio chunks. Ensure chunks have compatible shapes "
|
||||
f"for concatenation along dimension {concat_dim}. Original error: {e}"
|
||||
)
|
||||
|
||||
return reconstructed_tensor
|
||||
|
Reference in New Issue
Block a user