Пример #1
0
 def test_encodeEnergy_dct1_sobreposto(self):
     encoded = cd.encodeEnergy(np.array([1, 2, 3, 4, 1, 2, 3, 4]), 2, 2, dct1, 2)
     self.assertTrue(np.allclose(encoded.getDados(), [15, -4, 0, -1, 15, 4, 0, -5, 15, -4, 0, -1]))
Пример #2
0
import dcts.dct1 as dct1
import dcts.dct2 as dct2
import dcts.dct3 as dct3
import dcts.dct4 as dct4
import time

codec.addAlg(dct1)
codec.addAlg(dct2)
codec.addAlg(dct3)
codec.addAlg(dct4)


def current_milli_time():
    return int(round(time.time() * 1000))


print('Tempo Encode,Tempo Decode')
for i in range(50):
    fs, audData = wv.open_wave("./waves/f0001038.16k.WAV")

    be = current_milli_time()
    encoded = codec.encodeEnergy(audData, fs, 0.02, dct2, sobreposicao=50)
    ae = current_milli_time()

    encoded.setPorcentagemDescarte(0.85)

    bd = current_milli_time()
    rest = codec.decodeEnergy(encoded)
    ad = current_milli_time()
    print(ae - be, ',', ad - bd)
Пример #3
0
 def test_encodeEnergy_dct1(self):
     encoded = cd.encodeEnergy(np.array([1, 2, 3, 4, 1, 2, 3, 4]), 2, 2, dct1)
     encoded.setPorcentagemDescarte(0.5)
     
     result = cd.decodeEnergy(encoded)
     self.assertTrue(np.allclose(result, [1.1666667, 1.8333333, 3.1666667, 3.8333333, 1.1666667, 1.8333333, 3.1666667, 3.8333333]))
Пример #4
0
 def test_encodeEnergy_dct1(self):
     encoded = cd.encodeEnergy(np.array([1, 2, 3, 4, 1, 2, 3, 4]), 2, 2, dct1)
     encoded.setPorcentagemDescarte(0.5)
     self.assertTrue(np.allclose(encoded.getDados(), [15, -4, 0, 0, 15, -4, 0, 0]))
Пример #5
0
 def test_encodeEnergy_desordenado_com_eliminacao(self):
     result = cd.encodeEnergy(np.array([3, 2, 1, 4, 1, 4, 2, 3]), 2, 2, mock_alg)
     result.setPorcentagemDescarte(0.5)
     self.assertTrue(np.array_equal(result.getDados(), [7, 0, 0, 9, 0, 9, 0, 7]))
Пример #6
0
 def test_encodeEnergy_com_eliminacao(self):
     result = cd.encodeEnergy(np.array([1, 2, 3, 4, 1, 2, 3, 4]), 2, 2, mock_alg)
     result.setPorcentagemDescarte(0.5)
     self.assertTrue(np.array_equal(result.getDados(), [0, 0, 7, 9, 0, 0, 7, 9]))
Пример #7
0
 def test_encodeEnergy(self):
     result = cd.encodeEnergy(np.array([1, 2, 3, 4, 1, 2, 3, 4]), 2, 2, mock_alg)
     self.assertTrue(np.array_equal(result.getDados(), [3, 5, 7, 9, 3, 5, 7, 9]))