old_contents: import pytest
  import general
  from scipy.io import wavfile
  import numpy as np
  import scipy.io as sio
  
  
  @pytest.fixture
  def speech_raw():
      x = wavfile.read("test_files/test_speech_raw_22050.wav")[1]
      return x / 2. ** 15
  
  
  @pytest.fixture
  def noise_raw():
      x = wavfile.read("test_files/test_noise_raw_22050.wav")[1]
      return x / 2. ** 15
  
  
  @pytest.fixture
  def mix_0dB():
      x = wavfile.read("test_files/test_mix_0dB_22050.wav")[1]
      return x / 2. ** 15
  
  
  @pytest.fixture
  def noise_65dB():
      x_65 = wavfile.read("test_files/test_noise_65dB_22050.wav")[1]
      return x_65 / 2. ** 15
  
  
  def test_set_level(noise_raw, noise_65dB):
      x65 = general.setdbspl(noise_raw, 65)
      np.testing.assert_allclose(x65, noise_65dB, atol=1e-4)
  
  
  def test_envelope_extraction():
      mat = sio.loadmat("./test_files/test_envelope.mat")
      x = mat['signal'][0]
      target = mat['envelope'][0]
      envelope = general.hilbert_envelope(x)
      np.testing.assert_allclose(envelope, target, atol=1e-4)
  
new_contents: import pytest
  import general
  from scipy.io import wavfile
  import numpy as np
  import scipy.io as sio
  
  
  @pytest.fixture
  def speech_raw():
      x = wavfile.read("test_files/test_speech_raw_22050.wav")[1]
      return x / 2. ** 15
  
  
  @pytest.fixture
  def noise_raw():
      x = wavfile.read("test_files/test_noise_raw_22050.wav")[1]
      return x / 2. ** 15
  
  
  @pytest.fixture
  def mix_0dB():
      x = wavfile.read("test_files/test_mix_0dB_22050.wav")[1]
      return x / 2. ** 15
  
  
  @pytest.fixture
  def noise_65dB():
      x_65 = wavfile.read("test_files/test_noise_65dB_22050.wav")[1]
      return x_65 / 2. ** 15
  
  
  def test_set_level(noise_raw, noise_65dB):
      x65 = general.setdbspl(noise_raw, 65)
      np.testing.assert_allclose(x65, noise_65dB, atol=1e-4)
  
  
  def test_mix_speech_and_noise_0dB(speech_raw, noise_raw, mix_0dB):
      speech65 = general.setdbspl(speech_raw, 65)
      noise65 = general.setdbspl(noise_raw, 65)
      mixed = speech65 + noise65
      np.testing.assert_allclose(mixed, mix_0dB, atol=1e-4)
  
  
  def test_envelope_extraction():
      mat = sio.loadmat("./test_files/test_envelope.mat")
      x = mat['signal'][0]
      target = mat['envelope'][0]
      envelope = general.hilbert_envelope(x)
      np.testing.assert_allclose(envelope, target, atol=1e-4)
  
subject: Test mixing at given SNR