Ver Fonte

feat(audio): add noise injection for RMSNorm stability testing

沉默の金 há 5 meses atrás
pai
commit
19055d5726
2 ficheiros alterados com 6 adições e 15 exclusões
  1. 1 13
      .github/workflows/build.yml
  2. 5 2
      scripts/generate_test_audio.py

+ 1 - 13
.github/workflows/build.yml

@@ -65,19 +65,7 @@ jobs:
           
       - name: Generate Test Audio
         run: |
-          python -c "
-          import numpy as np
-          import scipy.io.wavfile as wav
-          sr = 44100
-          duration = 5.0
-          t = np.linspace(0, duration, int(sr * duration))
-          # Create a more complex test signal
-          left = (np.sin(2 * np.pi * 440 * t) + 0.5 * np.sin(2 * np.pi * 880 * t)) * 0.3
-          right = (np.sin(2 * np.pi * 660 * t) + 0.5 * np.sin(2 * np.pi * 1320 * t)) * 0.3
-          stereo = np.stack([left, right], axis=1).astype(np.float32)
-          wav.write('test_audio.wav', sr, stereo)
-          print(f'Generated test audio: {len(t)} samples, {duration}s')
-          "
+          python scripts/generate_test_audio.py --output test_audio.wav --duration 5.0 --sample-rate 44100
           
       - name: Generate Test Data
         run: |

+ 5 - 2
scripts/generate_test_audio.py

@@ -62,14 +62,17 @@ def generate_test_audio(
         + 0.10 * np.sin(2 * np.pi * 82.41 * t)  # E2 sub-bass
     )
 
+    # Add Gaussian noise to prevent zero-signal bands (crucial for RMSNorm stability)
+    noise = np.random.normal(0, 0.001, t.shape).astype(np.float32)
+
     # Add slight amplitude envelope to make it more interesting
     envelope = np.ones_like(t)
     fade_samples = int(0.1 * sample_rate)  # 100ms fade
     envelope[:fade_samples] = np.linspace(0, 1, fade_samples)
     envelope[-fade_samples:] = np.linspace(1, 0, fade_samples)
 
-    # Mix vocals and accompaniment
-    mix = (vocals + accompaniment) * envelope
+    # Mix vocals, accompaniment, and noise
+    mix = (vocals + accompaniment) * envelope + noise
 
     # Normalize to prevent clipping
     max_val = np.max(np.abs(mix))