Skip to content

Commit

Permalink
Update test_resampler.py
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Sep 26, 2024
1 parent fbeefa7 commit e0505ce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions livekit-rtc/tests/test_resampler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from livekit.rtc import AudioResampler, AudioResamplerQuality
import time
import wave
import os


def test_audio_resampler():
with wave.open("test_audio.wav", "rb") as wf_in:
current_dir = os.path.dirname(os.path.abspath(__file__))
wav_file_path = os.path.join(current_dir, "test_audio.wav")

# Open the wave file
with wave.open(wav_file_path, "rb") as wf_in:
n_channels = wf_in.getnchannels()
sampwidth = wf_in.getsampwidth()
n_frames = wf_in.getnframes()
Expand All @@ -27,7 +32,7 @@ def test_audio_resampler():
output_frames = []
for i in range(nb_runs):
output_frames = []
resampler = AudioResampler(44100, 16000, quality=quality)
resampler = AudioResampler(44100, 8000, quality=quality)

start_time = time.perf_counter()

Expand Down Expand Up @@ -55,5 +60,5 @@ def test_audio_resampler():
with wave.open(f"audio_resampled_{quality.name}.wav", "wb") as wf_out:
wf_out.setnchannels(n_channels)
wf_out.setsampwidth(sampwidth)
wf_out.setframerate(16000)
wf_out.setframerate(8000)
wf_out.writeframes(output_data)

0 comments on commit e0505ce

Please sign in to comment.