Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Candre Nathan
Grands cris d hommes minuscules
Commits
24ca170c
Commit
24ca170c
authored
Apr 04, 2021
by
LucasDANIELE
Browse files
Ajout d'un tri sur la forme du cri
parent
0a77f7ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
cells.py
View file @
24ca170c
...
...
@@ -13,8 +13,8 @@ import numpy as np
import
fcts
as
fcts
import
importlib
import
frequency_estimator
as
f0
importlib
.
reload
(
fcts
)
importlib
.
reload
(
f0
)
#
importlib.reload(fcts)
#
importlib.reload(f0)
#%%
################################################
...
...
@@ -22,8 +22,8 @@ importlib.reload(f0)
################################################
start_time
=
time
()
bEnSec
=
(
0
*
60
)
duree
=
3600
bEnSec
=
0
*
3600
+
0
*
60
+
0
duree
=
0
*
3600
+
1
*
60
+
0
samplerate
,
dataLR
=
wavfile
.
read
(
"input/male2.wav"
)
#On lit le fichier qui a des infos oreille gauche, oreille droite
dataL
=
dataLR
[:,
0
]
#On recupère que le son de l'oreille gauche
...
...
@@ -55,15 +55,20 @@ dataCut = fcts.decouperExtraits(data, 2500, 0.1, samplerate, 20000)
dataCutCris
,
freqArray
=
fcts
.
garderUniquementCris
(
samplerate
,
0.38
,
0.6
,
250
,
450
,
f0
.
freq_from_HPS
,
dataCut
,
data
)
for
i
in
range
(
len
(
dataCutCris
)):
#
fcts.aff("cri"+str(i), t, np.asarray(data
CutCris[i
]))
fcts
.
aff
(
"cri"
+
str
(
i
),
t
,
np
.
asarray
(
data
[
d
:
f
]))
d
=
dataCutCris
[
i
][
0
]
f
=
dataCutCris
[
i
][
1
]
fcts
.
listen
(
"output/cri"
+
str
(
i
)
+
".wav"
,
samplerate
,
np
.
asarray
(
data
[
d
:
f
]))
print
(
"enregistrement: "
+
str
(
i
))
print
(
"f0 -> "
+
str
(
np
.
round
(
freqArray
[
i
])))
print
(
"duration -> "
+
str
((
f
-
d
)
/
samplerate
))
print
(
"sum -> "
+
str
(
np
.
sum
(
abs
(
data
[
d
:
f
]))))
print
(
"________________"
)
print
(
"*************************"
)
print
(
"* enregistrement: "
+
str
(
i
))
print
(
"*************************"
)
print
(
"* f0 -> "
+
str
(
np
.
round
(
freqArray
[
i
])))
print
(
"* duration -> "
+
str
((
f
-
d
)
/
samplerate
))
print
(
"* quantité de son à 5% -> "
+
str
(
np
.
sum
(
abs
(
data
[
d
:
d
+
int
(
np
.
round
(
0.05
*
(
f
-
d
)))]))
/
np
.
sum
(
abs
(
data
[
d
:
f
]))))
print
(
"*************************"
)
print
(
""
)
print
(
"_________________________"
)
print
(
""
)
print
(
np
.
mean
(
freqArray
))
print
(
np
.
std
(
freqArray
))
...
...
fcts.py
View file @
24ca170c
...
...
@@ -66,8 +66,23 @@ def garderUniquementCris(sampleRate,tMin, tMax, fMin, fMax, f0Func, dataCut, dat
if
((
f
-
d
>
nSamplesMin
)
&
(
f
-
d
<
nSamplesMax
)):
freq
=
np
.
round
(
f0Func
(
np
.
asarray
(
data
[
d
:
f
]),
sampleRate
))
if
((
freq
>
fMin
)
&
(
freq
<
fMax
)):
res
.
append
(
dataCut
[
i
])
freqs
.
append
(
freq
)
quantiteDeSonA5Pourcents
=
np
.
sum
(
abs
(
data
[
d
:
d
+
int
(
np
.
round
(
0.05
*
(
f
-
d
)))]))
quantiteDeSon
=
np
.
sum
(
abs
(
data
[
d
:
f
]))
if
(
quantiteDeSonA5Pourcents
/
quantiteDeSon
>
0.065
):
res
.
append
(
dataCut
[
i
])
freqs
.
append
(
freq
)
listen
(
"output/cri"
+
str
(
i
)
+
".wav"
,
sampleRate
,
np
.
asarray
(
data
[
d
:
f
]))
print
(
"*************************"
)
print
(
"* enregistrement: "
+
str
(
i
))
print
(
"*************************"
)
print
(
"* f0 -> "
+
str
(
freq
))
print
(
"* duration -> "
+
str
((
f
-
d
)
/
sampleRate
))
print
(
"* quantité de son à 5% -> "
+
str
(
np
.
sum
(
abs
(
data
[
d
:
d
+
int
(
np
.
round
(
0.05
*
(
f
-
d
)))]))
/
np
.
sum
(
abs
(
data
[
d
:
f
]))))
print
(
"*************************"
)
print
(
""
)
print
(
"_________________________"
)
print
(
""
)
return
res
,
freqs
...
...
frequency_estimator.py
View file @
24ca170c
...
...
@@ -3,11 +3,7 @@ from numpy.fft import rfft
from
numpy
import
argmax
,
mean
,
diff
,
log
,
nonzero
from
scipy.signal
import
blackmanharris
,
correlate
from
time
import
time
import
sys
try
:
import
soundfile
as
sf
except
ImportError
:
from
scikits.audiolab
import
flacread
from
parabolic
import
parabolic
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment