def test(): strInfo = "NanaliCCC" bytes = getInfoOfBytes(strInfo) #print bytes nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/bird.wav") wave_data = setInfoWithLSB(wave_data, bytes) params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') disposeWav.write_wave("../wavFile/result1.wav",params,wave_data) nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/bird.wav") wave_data = setInfoWithMCLT(wave_data,bytes) params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') disposeWav.write_wave("../wavFile/result2.wav",params,wave_data) nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/bird.wav") wave_data = setInfoWithFFT(wave_data,bytes) params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') disposeWav.write_wave("../wavFile/result3.wav",params,wave_data)
def test(): strInfo = "http://cslt.riit.tsinghua.edu.cn/" bytes = getInfoOfBytes(strInfo) #print bytes nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/outputfile.wav") wave_data = setInfoWithLSB(wave_data, bytes) params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') disposeWav.write_wave("../wavFile/result1.wav",params,wave_data) nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/outputfile.wav") wave_data = setInfoWithMCLT(wave_data,bytes) params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') disposeWav.write_wave("../wavFile/result2.wav",params,wave_data) nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/outputfile.wav") wave_data = setInfoWithFFT(wave_data,bytes) params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') disposeWav.write_wave("../wavFile/result3.wav",params,wave_data)
def test(): strInfo = "http://cslt.riit.tsinghua.edu.cn/" nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/result1.wav") BlockLen = 4096 infoLen = len(strInfo) info = extractInfoWithLSB(wave_data, BlockLen, infoLen) print info,'\n\n' nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/result2.wav") #nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/disposedWav.wav") BlockLen = 4096 infoLen = len(strInfo) info = extractInfoWithMCLT(wave_data, BlockLen, infoLen) print info,'\n\n' nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/result3.wav") BlockLen = 4096 infoLen = len(strInfo) info = extractInfoWithFFT(wave_data, BlockLen, infoLen) print info,'\n\n'
def test(): nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data( "../wavFile/result1.wav") BlockLen = 4096 infoLen = 9 info = extractInfoWithLSB(wave_data, BlockLen, infoLen) print info nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data( "../wavFile/result2.wav") #nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("/root/record1.wav") BlockLen = 4096 infoLen = 9 info = extractInfoWithMCLT(wave_data, BlockLen, infoLen) print info nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data( "../wavFile/result3.wav") BlockLen = 4096 infoLen = 9 info = extractInfoWithFFT(wave_data, BlockLen, infoLen) print info
def test(): strInfo = "http://cslt.riit.tsinghua.edu.cn/" nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data( "../wavFile/result1.wav") BlockLen = 4096 infoLen = len(strInfo) info = extractInfoWithLSB(wave_data, BlockLen, infoLen) print info, '\n\n' nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data( "../wavFile/result2.wav") #nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/disposedWav.wav") BlockLen = 4096 infoLen = len(strInfo) info = extractInfoWithMCLT(wave_data, BlockLen, infoLen) print info, '\n\n' nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data( "../wavFile/result3.wav") BlockLen = 4096 infoLen = len(strInfo) info = extractInfoWithFFT(wave_data, BlockLen, infoLen) print info, '\n\n'
def test(): nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data( "../wavFile/test1.wav") x = range(4000, 8000, 2) BL = 32 B = len(x) * 2 / BL - 1 for i in range(B - 1): if i == 0: print x[:BL] continue X_prev = MCLT(x[(i - 1) * BL / 2:(i + 1) * BL / 2]) X_curr = MCLT(x[(i) * BL / 2:(i + 2) * BL / 2]) X_next = MCLT(x[(i + 1) * BL / 2:(i + 3) * BL / 2]) X = X_curr y = IMCLT(X) #将嵌入信息后的复数域信息反变换到实数域 y_prev = IMCLT(X_prev)[BL / 2:] y_next = IMCLT(X_next)[:BL / 2] y = np.array(y_prev + y_next) + np.array(y) print y[BL / 2:] print x[-BL / 2:] print "\n\n\n" for i in range(B - 1): if i == 0: print x[:BL] continue X_prev = FastMCLT(x[(i - 1) * BL / 2:(i + 1) * BL / 2]) X_curr = FastMCLT(x[(i) * BL / 2:(i + 2) * BL / 2]) X_next = FastMCLT(x[(i + 1) * BL / 2:(i + 3) * BL / 2]) X = X_curr y = FastIMCLT(X) #将嵌入信息后的复数域信息反变换到实数域 y_prev = FastIMCLT(X_prev).tolist()[BL / 2:] y_next = FastIMCLT(X_next).tolist()[:BL / 2] y = np.array(y_prev + y_next) + y print y[BL / 2:] print x[-BL / 2:]
def test(): nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/test1.wav") x = range(4000,8000,2) BL = 32 B = len(x)*2/BL - 1 for i in range(B-1): if i == 0: print x[:BL] continue X_prev = MCLT(x[(i-1)*BL/2:(i+1)*BL/2]) X_curr = MCLT(x[(i)*BL/2:(i+2)*BL/2]) X_next = MCLT(x[(i+1)*BL/2:(i+3)*BL/2]) X = X_curr y = IMCLT(X) #将嵌入信息后的复数域信息反变换到实数域 y_prev = IMCLT(X_prev)[BL/2:] y_next = IMCLT(X_next)[:BL/2] y = np.array(y_prev + y_next) + np.array(y) print y[BL/2:] print x[-BL/2:] print "\n\n\n" for i in range(B-1): if i == 0: print x[:BL] continue X_prev = FastMCLT(x[(i-1)*BL/2:(i+1)*BL/2]) X_curr = FastMCLT(x[(i)*BL/2:(i+2)*BL/2]) X_next = FastMCLT(x[(i+1)*BL/2:(i+3)*BL/2]) X = X_curr y = FastIMCLT(X) #将嵌入信息后的复数域信息反变换到实数域 y_prev = FastIMCLT(X_prev).tolist()[BL/2:] y_next = FastIMCLT(X_next).tolist()[:BL/2] y = np.array(y_prev + y_next) + y print y[BL/2:] print x[-BL/2:]
import wave import matplotlib.pyplot as plt import numpy as np import math import disposeWav import addInfoToWav import extractInfoFromWav import MCLT BlockLen = 4096 strInfo = "http://cslt.riit.tsinghua.edu.cn/" bytes = addInfoToWav.getInfoOfBytes(strInfo) infoLen = len(strInfo) nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/outputfile.wav") params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') #plt.subplot(211) #plt.plot(time, wave_data[0]) wave_data = addInfoToWav.setInfoWithMCLT(wave_data,bytes) #plt.subplot(212) #plt.plot(time, wave_data[0], c='g') disposeWav.write_wave("../wavFile/result2.wav",params,wave_data) info = extractInfoFromWav.extractInfoWithMCLT(wave_data, BlockLen, infoLen) print info #The following test the record audios which have been added watermarking. #加密音频录音后得到的音频
import wave import matplotlib.pyplot as plt import numpy as np import math import disposeWav import addInfoToWav import extractInfoFromWav import MCLT BlockLen = 4096 strInfo = "baidu.com" bytes = addInfoToWav.getInfoOfBytes(strInfo) infoLen = len(strInfo) nchannels, sampwidth, framerate, nframes, wave_data, time = disposeWav.read_wave_data("../wavFile/duck.wav") plt.subplot(211) plt.plot(time, wave_data[0]) wave_data = addInfoToWav.setInfoWithMCLT(wave_data,bytes) plt.subplot(212) plt.plot(time, wave_data[0], c='g') params = (nchannels, sampwidth, framerate, nframes,'NONE', 'not compressed') disposeWav.write_wave("../wavFile/result2.wav",params,wave_data) info = extractInfoFromWav.extractInfoWithMCLT(wave_data, BlockLen, infoLen) print info #The following test the record audios which have been added watermarking. #加密音频录音后得到的音频