Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

torchaudio.transforms.Resample outputs repeating blocks of kernel values instead of resampled audio (Dimension/Convolution bug)

Abierto
#1,574 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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

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

bug

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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/TorchSharp

Todos los issues de dotnet/TorchSharp

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.