Commit 24ca170c authored by LucasDANIELE's avatar LucasDANIELE
Browse files

Ajout d'un tri sur la forme du cri

parent 0a77f7ba
...@@ -13,8 +13,8 @@ import numpy as np ...@@ -13,8 +13,8 @@ import numpy as np
import fcts as fcts import fcts as fcts
import importlib import importlib
import frequency_estimator as f0 import frequency_estimator as f0
importlib.reload(fcts) # importlib.reload(fcts)
importlib.reload(f0) # importlib.reload(f0)
#%% #%%
################################################ ################################################
...@@ -22,8 +22,8 @@ importlib.reload(f0) ...@@ -22,8 +22,8 @@ importlib.reload(f0)
################################################ ################################################
start_time = time() start_time = time()
bEnSec = (0*60) bEnSec = 0*3600 + 0*60 + 0
duree = 3600 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 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 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) ...@@ -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) dataCutCris, freqArray = fcts.garderUniquementCris(samplerate,0.38,0.6,250,450,f0.freq_from_HPS, dataCut, data)
for i in range(len(dataCutCris)): for i in range(len(dataCutCris)):
#fcts.aff("cri"+str(i), t, np.asarray(dataCutCris[i])) fcts.aff("cri"+str(i), t, np.asarray(data[d:f]))
d=dataCutCris[i][0] d=dataCutCris[i][0]
f=dataCutCris[i][1] f=dataCutCris[i][1]
fcts.listen("output/cri"+str(i)+".wav", samplerate, np.asarray(data[d:f])) fcts.listen("output/cri"+str(i)+".wav", samplerate, np.asarray(data[d:f]))
print("enregistrement: " + str(i)) print("*************************")
print("f0 -> " + str(np.round(freqArray[i]))) print("* enregistrement: " + str(i))
print("duration -> " + str((f-d)/samplerate)) print("*************************")
print("sum -> " + str(np.sum(abs(data[d:f])))) print("* f0 -> " + str(np.round(freqArray[i])))
print("________________") 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.mean(freqArray))
print(np.std(freqArray)) print(np.std(freqArray))
......
...@@ -66,8 +66,23 @@ def garderUniquementCris(sampleRate,tMin, tMax, fMin, fMax, f0Func, dataCut, dat ...@@ -66,8 +66,23 @@ def garderUniquementCris(sampleRate,tMin, tMax, fMin, fMax, f0Func, dataCut, dat
if((f-d>nSamplesMin) & (f-d<nSamplesMax)): if((f-d>nSamplesMin) & (f-d<nSamplesMax)):
freq = np.round(f0Func(np.asarray(data[d:f]),sampleRate)) freq = np.round(f0Func(np.asarray(data[d:f]),sampleRate))
if((freq>fMin) & (freq<fMax)): if((freq>fMin) & (freq<fMax)):
res.append(dataCut[i]) quantiteDeSonA5Pourcents = np.sum(abs(data[d:d+int(np.round(0.05*(f-d)))]))
freqs.append(freq) 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 return res, freqs
......
...@@ -3,11 +3,7 @@ from numpy.fft import rfft ...@@ -3,11 +3,7 @@ from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate from scipy.signal import blackmanharris, correlate
from time import time from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
from parabolic import parabolic from parabolic import parabolic
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment