torchaudio.transforms.Resample outputs repeating blocks of kernel values instead of resampled audio (Dimension/Convolution bug)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 56/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- csharp, pytorch
- Área
- machine-learning
Línea de trabajo
Comienza por la implementación en C# de torchaudio.transforms.Resample y functional._apply_sinc_resample_kernel, y luego inspecciona cómo torch.nn.functional.conv1d recibe la entrada [1, Samples] y cómo se consume output.data().ToArray(). Reproduce el caso de 22050 Hz a 16000 Hz y verifica que el resultado sea una forma de onda unidimensional que coincida con la interpolación sinc con ventana de Python torchaudio bit a bit, en lugar de bloques repetidos de 320 valores.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description:
There is a severe bug in the C# translation of torchaudio.transforms.Resample / functional._apply_sinc_resample_kernel when converting audio (e.g., from 22050 Hz to 16000 Hz).
Instead of a cleanly resampled waveform, the output contains repeating blocks of identical values matching the upsampling factor of the kernel (exactly 320 repeating float values).
Root Cause:
The C# implementation of _apply_sinc_resample_kernel translates the original Python code but mishandles tensor dimensions when invoking torch.nn.functional.conv1d.
When downsampling from 22050 to 16000, the calculated kernel has the shape [320, 1, 459].
Because the C# wrapper applies conv1d with a 1D input tensor improperly shaped or matched, the convolution is applied across channels instead of across time.
This results in an output shape of [1, 320, NewSamples].
When reading the tensor back to C# via .data().ToArray(), the data layout is flattened linearly, causing the user to read the 320 kernel-channel values for each time step sequentially. This looks like a static block of 320 repeating values. The required reshaping/transposing to fold the 320 channels back into the time axis is either missing or broken in the C# port.
To Reproduce:csharp
// Input: Float array of 22050Hz audio
float[] signal = ...
using var nativeTensor = torch.from_array(signal).to(torch.ScalarType.Float32);
using var inputTensor = nativeTensor.unsqueeze(0); // [1, Samples]
using var resampler = torchaudio.transforms.Resample(orig_freq: 22050, new_freq: 16000);
using var output = resampler.forward(inputTensor);
// Look at the raw float/byte array: It contains blocks of 320 repeating values
float[] result = output.squeeze(0).ToArray();
Behavior:
The output should match the bit-accurate windowed sinc interpolation of Python's torchaudio.
- Lenguaje dominante
- C#
- Estrellas
- 1.9k
- Forks
- 230
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/TorchSharp
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
dotnet/TorchSharp#1583 ·
-
Dificultad 4/5 Más de una semana Aptitud para principiantes 30/100
dotnet/TorchSharp#1581 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
dotnet/TorchSharp#1579 ·
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
dotnet/TorchSharp#1567 ·
-
question
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
dotnet/TorchSharp#1557 ·
Todos los issues de dotnet/TorchSharp
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
:watch: Not Triaged advanced-concepts/subsvc dotnet-csharp/svc
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
enhancement no-stack-trace
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
greenshot/greenshot#1618 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
microsoft/aspire.dev#1962 ·
Los mantenedores suelen responder en 1 día
-
needs-area-label
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día