comparison tests/test_util.py @ 321:903b5e1e8af9

Clean up tests
author Amine Sehili <amine.sehili@gmail.com>
date Sat, 19 Oct 2019 15:01:38 +0100
parents 18a9f0dcdaae
children 9f17aa9a4018
comparison
equal deleted inserted replaced
320:06a39e279cd7 321:903b5e1e8af9
1 from unittest import TestCase 1 from unittest import TestCase
2 import math 2 import math
3 from array import array 3 from array import array
4 from genty import genty, genty_dataset 4 from genty import genty, genty_dataset
5 from auditok.util import AudioEnergyValidator 5 from auditok.util import AudioEnergyValidator
6 from auditok.io import DATA_FORMAT 6 from auditok.signal import FORMAT
7 7
8 8
9 def _sample_generator(*data_buffers): 9 def _sample_generator(*data_buffers):
10 """ 10 """
11 Takes a list of many mono audio data buffers and makes a sample generator 11 Takes a list of many mono audio data buffers and makes a sample generator
27 """ 27 """
28 assert frequency <= sampling_rate / 2 28 assert frequency <= sampling_rate / 2
29 max_value = (2 ** (sample_width * 8) // 2) - 1 29 max_value = (2 ** (sample_width * 8) // 2) - 1
30 if volume > max_value: 30 if volume > max_value:
31 volume = max_value 31 volume = max_value
32 fmt = DATA_FORMAT[sample_width] 32 fmt = FORMAT[sample_width]
33 total_samples = int(sampling_rate * duration_sec) 33 total_samples = int(sampling_rate * duration_sec)
34 step = frequency / sampling_rate 34 step = frequency / sampling_rate
35 two_pi_step = 2 * math.pi * step 35 two_pi_step = 2 * math.pi * step
36 data = array( 36 data = array(
37 fmt, 37 fmt,