AudioFrequencyConverter silently turns floating-point WAV input into silence
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- numpy, python
- Domain
- audio-video-rtc
Research direction
Start in pyrit/converter/audio_frequency_converter.py at the cast immediately before wavfile.write, and reproduce the issue through convert_async with the provided float32 WAV example. Verify that a zero-shift conversion no longer produces an all-zero output and that the floating-point waveform is preserved or correctly scaled to PCM.
Written by the indexing model from the issue text.
Description
Describe the bug
AudioFrequencyConverter reads floating-point WAV data successfully, but casts the shifted samples directly to int16 without scaling. A valid floating-point signal whose samples have magnitude below 1 is therefore written as all-zero audio. Conversion returns successfully, so the caller receives a silent artifact rather than an error. Even shift_value=0 loses the signal.
The cast is in pyrit/converter/audio_frequency_converter.py, immediately before wavfile.write. Existing success tests exercise int16 data. This differs from #2356, which fixed stereo broadcasting.
Steps/Code to Reproduce
Run from an environment with PyRIT installed:
import asyncio
import tempfile
from pathlib import Path
import numpy as np
from scipy.io import wavfile
from pyrit.converter import AudioFrequencyConverter
from pyrit.memory import CentralMemory, SQLiteMemory
async def main_async():
with tempfile.TemporaryDirectory() as directory:
memory = SQLiteMemory(db_path=':memory:')
memory.results_path = directory
CentralMemory.set_memory_instance(memory)
try:
source = Path(directory) / 'float.wav'
samples = np.array([0.0, 0.5, -0.5, 0.25], dtype=np.float32)
wavfile.write(source, 8000, samples)
result = await AudioFrequencyConverter(shift_value=0).convert_async(prompt=str(source))
rate, output = wavfile.read(result.output_text)
print('frequency:', output.dtype, output.tolist())
finally:
memory.dispose_engine()
asyncio.run(main_async())
Expected Results
A zero frequency shift preserves the input waveform and amplitude. Floating-point samples should either retain their representation or be correctly scaled if converted to PCM; silently truncating them is incorrect.
Actual Results
frequency: int16 [0, 0, 0, 0]
The input is float32 [0.0, 0.5, -0.5, 0.25].
Versions
Linux, Python 3.12.3, PyRIT 1.2.0.dev0 at 8934a3c4, NumPy 2.5.3, SciPy 1.18.1. Reproduced locally through the public convert_async methods with real WAV files; no model or external service is used.
- Dominant language
- Python
- Stars
- 4.5k
- Forks
- 896
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 220
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/PyRIT
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 2 days
-
Bug: triage GUI help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
microsoft/PyRIT#2868 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
feature-request
Difficulty 5/5 Over a week Newbie friendliness 30/100
Maintainers usually reply within 2 days
Similar issues
-
bug server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sportsdataverse/sportsdataverse-py#641 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
googleapis/google-cloud-python#18532 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day