Пример #1
0
def evaluate(ref, test, saida):
    fsRef, ref = wv.open_wave(ref)
    fsTest, test = wv.open_wave(test)
    amostrasPorQuadro = int(fsRef * 0.02)

    srn_seg = evaluate_snr_seg(ref, test, int(fsRef * 0.02))
    snr_total = evaluate_snr_total(ref, test)

    file = open(saida, "w")
    file.write("snr_seg,snr_total")
    file.write("\n")
    file.write("%f,%f\n" % (srn_seg, snr_total))
    file.close()

    print(srn_seg)
    print(snr_total)
Пример #2
0
import time
import os
import evaluation.evaluation as eval
from shutil import copyfile


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


prefixoNome = "f0001038.16k.q20ms.dct2.descarta160.s0-2"
os.makedirs('./result/' + prefixoNome)
origem = "f0001038.16k.WAV"
copyfile("./waves/" + origem, "./result/%s/%s" % (prefixoNome, origem))

fs, audData = wv.open_wave("./waves/f0001038.16k.WAV")

b = current_milli_time()
encoded = codec.encode(audData, fs, 0.02, dct2, 0)
a = current_milli_time()
print('Tempo de encode: ', a - b)

encoded.descartar(160)
#Arquivo comprimido
encoded.saveToFile("./result/%s/encoded.dct" % prefixoNome)

b = current_milli_time()
decoded = codec.decodeFromEncoded(encoded, dct2)
a = current_milli_time()
print('Tempo de decode: ', a - b)
Пример #3
0
import time
import os
from shutil import copyfile


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


prefixoNome = "f0001038.16k.q20ms.coif3.dec3.removeCd0a1.s20"
os.makedirs('./result/' + prefixoNome)
origem = "f0001038.16k.WAV"
copyfile("./waves/" + origem, "./result/%s/%s" % (prefixoNome, origem))

#Le dados do arquivo
fs, audData = wv.open_wave('./waves/' + origem)

#Aplica dwt(encode) e retorna objeto com todos
b = current_milli_time()
encoded = codec.encodeRemoveCD(audData, fs, 0.02, 'coif3', 3, sobreposicao=20)
a = current_milli_time()
print('Tempo de encode: ', a - b)

encoded.removerCDs(0, 1)

#Recuperando amostras a partir dos dados comprimidos em memoria
b = current_milli_time()
rest = codec.decode(
    encoded)  #aplica IDWT (decode) e retorna amostras recuperadas
a = current_milli_time()
print('Tempo de decode: ', a - b)
Пример #4
0
import dcts.wave as wv
from peaq.PEAQ import PEAQ

fs, ref = wv.open_wave("./waves/m0001006.WAV")
fs, test = wv.open_wave(
    "./waves/m0001006_metodo_sobreposicaode10_descarta160.wav")

nf = fs * 0.02

peaq = PEAQ(Amax=1, Fs=fs, NF=nf)

result = peaq.process(ref, test)

print(result)
Пример #5
0
import dcts.wave as wv
import evaluation.evaluation as eval
import numpy as np

fsRef, ref = wv.open_wave("./waves/f0001038.16k.WAV")
fsTest, test = wv.open_wave(
    "./result/f0001038.16k.q1s.db10.dec9.remove85percent.s0.wav")

srn_seg = eval.evaluate_snr_seg(ref, test, int(fsRef * 0.02), 0)

print(srn_seg)

snr_total = eval.evaluate_snr_total(ref, test)

print(snr_total)
Пример #6
0
codec.addAlg(dct1)
codec.addAlg(dct2)
codec.addAlg(dct3)
codec.addAlg(dct4)

prefixoNome = "f0001038.16k.q20ms.dct2.sorted50.s160"
os.makedirs('./result/' + prefixoNome)
origem = "f0001038.16k.WAV"
copyfile("./waves/" + origem, "./result/%s/%s" % (prefixoNome, origem))


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


fs, audData = wv.open_wave("./waves/" + origem)

b = current_milli_time()
encoded = codec.encodeEnergy(audData, fs, 0.02, dct2, sobreposicao=160)
a = current_milli_time()
print('Tempo de encode: ', a - b)

encoded.setPorcentagemDescarte(0.5)

b = current_milli_time()
rest = codec.decodeEnergy(encoded)
a = current_milli_time()
print('Tempo de decode: ', a - b)

#Arquivo comprimido
encoded.saveToFile("./result/%s/encoded.dct" % prefixoNome)
Пример #7
0
import dcts.codec as codec
import dcts.encoded as enc
import dcts.dct1 as dct1
import dcts.dct2 as dct2
import sys
import numpy as np

entrada = sys.argv[1]
descartes = int(sys.argv[2])
sobreposicao = int(sys.argv[3])
saida = sys.argv[4]

saidaWav = None
if len(sys.argv) > 5:
    saidaWav = sys.argv[5]

fs, audData = wv.open_wave(entrada)

encoded = codec.encode(audData, fs, 0.02, dct1, sobreposicao)

encodedData = encoded.getDadosComprimidos()
print(len(encodedData))
np.savez_compressed("result/teste1.npz", encodedData)
encodedData.astype('int16').tofile("result/aa.npy")

encoded.descartar(descartes)
encoded.saveToFile(saida)

if (saidaWav is not None):
    decoded = codec.decodeFromEncoded(encoded, dct1)
    wv.save_wave(saidaWav, encoded.fs, decoded, 16)