-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestAudio2.py
46 lines (33 loc) · 1.63 KB
/
testAudio2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import scipy as sp
import numpy as np
import matplotlib.pyplot as plt
import math
from helpers import wavFileToAudioVector, audioVectorToWavFile, addWhiteNoise,\
removeWhiteNoiseSVD
# import new_maedee_voice.wav as the audio vector maedataVector
currentDirectory = os.path.dirname(__file__)
fileToImport = "new_maedee_voice.wav"
fileLocation = os.path.join(currentDirectory, "Audio/", fileToImport)
(maedeeSampleRate, maedataVector) = wavFileToAudioVector(fileLocation)
# create whiteNoiseMaedataVector, store as file
whiteNoiseMaedataVector = addWhiteNoise(maedataVector, 0, 0.04, 10)
audioVectorToWavFile(whiteNoiseMaedataVector, maedeeSampleRate,\
"gaussian_0.04_new_maedee_voice")
testVector = np.random.rand(24000, 1)
testVector *= 20
# print(testVector.shape)
# print(testVector)
testVector = testVector.reshape(testVector.shape[0], 1)
# print(testVector)
# print(testVector.shape)
# cleanTestVector = removeWhiteNoiseSVD(testVector, 7500, 0.04, "LS", "AD",\
# "SQRT(M)*ETA", 1, "BLOCKWISE", 0.03, 0, debug=True)
cleanMaedataVector = removeWhiteNoiseSVD(whiteNoiseMaedataVector,\
maedeeSampleRate, 0.04, "MLS", "AD",\
"META^2", 1, "BLOCKWISE",\
windowDuration=0.03,\
overlapDuration=0.001,\
debug=True)
audioVectorToWavFile(cleanMaedataVector, maedeeSampleRate,\
"gaussian_0.04_MLS_AD_sqrtMeta_1.5_Blockwise_0.015")