-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestPlotBioSound.py
More file actions
122 lines (99 loc) · 3.42 KB
/
Copy pathtestPlotBioSound.py
File metadata and controls
122 lines (99 loc) · 3.42 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from soundsig.sound import BioSound
from soundsig.sound import WavFile
import os
import matplotlib.pyplot as plt
import numpy as np
# Read the matlab file that has all the cut Sounds
os.chdir('/Users/frederictheunissen/Documents/Data/Julie/FullVocalizationBank/h5files')
figdir = '/Users/frederictheunissen/Documents/Data/Julie/Acoustical Analysis/Figures Voice'
# Bird 1 DC
silence = np.zeros(10000)
totDCSound = np.zeros(5000)
totAgSound = np.zeros(5000)
myBioSound = BioSound()
myBioSound.readh5('LblBla4419_DC_2962.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/DC1_1.eps' % figdir)
totDCSound = np.append(totDCSound, myBioSound.sound)
totDCSound = np.append(totDCSound, silence)
myBioSound.readh5('LblBla4419_DC_2963.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/DC1_2.eps' % figdir)
totDCSound = np.append(totDCSound, myBioSound.sound)
totDCSound = np.append(totDCSound, silence)
myBioSound.readh5('LblBla4419_DC_2964.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/DC1_3.eps' % figdir)
totDCSound = np.append(totDCSound, myBioSound.sound)
totDCSound = np.append(totDCSound, silence)
totDCSound = np.append(totDCSound, silence)
# Bird 1 AG
myBioSound.readh5('LblBla4419_Ag_2927.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/Ag1_1.eps' % figdir)
totAgSound = np.append(totAgSound, myBioSound.sound)
totAgSound = np.append(totAgSound, silence)
myBioSound.readh5('LblBla4419_Ag_2928.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/Ag1_2.eps' % figdir)
totAgSound = np.append(totAgSound, myBioSound.sound)
totAgSound = np.append(totAgSound, silence)
myBioSound.readh5('LblBla4419_Ag_3167.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/Ag1_3.eps' % figdir)
totAgSound = np.append(totAgSound, myBioSound.sound)
totAgSound = np.append(totAgSound, silence)
totAgSound = np.append(totAgSound, silence)
# Bird 2
myBioSound.readh5('YelOra2575_DC_7668.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/DC2_1.eps' % figdir)
totDCSound = np.append(totDCSound, myBioSound.sound)
totDCSound = np.append(totDCSound, silence)
myBioSound.readh5('YelOra2575_DC_7669.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/DC2_2.eps' % figdir)
totDCSound = np.append(totDCSound, myBioSound.sound)
totDCSound = np.append(totDCSound, silence)
myBioSound.readh5('YelOra2575_DC_7670.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/DC2_3.eps' % figdir)
totDCSound = np.append(totDCSound, myBioSound.sound)
totDCSound = np.append(totDCSound, silence)
myBioSound.readh5('YelOra2575_Ag_7579.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/AG2_1.eps' % figdir)
totAgSound = np.append(totAgSound, myBioSound.sound)
totAgSound = np.append(totAgSound, silence)
myBioSound.readh5('YelOra2575_Ag_7923.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/AG2_2.eps' % figdir)
totAgSound = np.append(totAgSound, myBioSound.sound)
totAgSound = np.append(totAgSound, silence)
myBioSound.readh5('YelOra2575_Ag_7937.h5')
myBioSound.plot()
plt.figure(1)
plt.savefig('%s/AG2_3.eps' % figdir)
totAgSound = np.append(totAgSound, myBioSound.sound)
totAgSound = np.append(totAgSound, silence)
# myBioSound.play()
# Write the two wav files
soundWavOut = WavFile()
soundWavOut.sample_depth = 2 # in bytes
soundWavOut.sample_rate = myBioSound.samprate # in Hz
soundWavOut.num_channels = 1
soundWavOut.data = totDCSound
soundWavOut.to_wav('%s/DCSounds.wav' % figdir, normalize=True)
soundWavOut.data = totAgSound
soundWavOut.to_wav('%s/AgSounds.wav' % figdir, normalize=True)