Commit a1502a20 authored by LucasDANIELE's avatar LucasDANIELE
Browse files

Nettoyage + optimisation frs hps

parent 0754abe0
......@@ -12,7 +12,7 @@ import numpy as np
import matplotlib.pyplot as plt
import fcts as fcts
import importlib
import frequency_estimator.frequency_estimator as f0
import frequency_estimator as f0
importlib.reload(fcts)
importlib.reload(f0)
......@@ -21,8 +21,8 @@ importlib.reload(f0)
# Extraction des données
################################################
#%%
bEnSec = (0*60+0)
duree = 500
bEnSec = (0*60)
duree = 60
samplerate, dataLR = wavfile.read("input/male.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
......@@ -44,20 +44,18 @@ fcts.listen("output/extrait.wav", samplerate, data)
################################################
#%%
dataCut = fcts.decouperExtraits(data)
print(str(len(dataCut))+" cris")
print(str(len(dataCut))+" cuts")
################################################
# Support temporel uniquement cris
################################################
#%%
dataCutCris = fcts.garderUniquementCris(samplerate,0.5,1.5,250,2000,f0.freq_from_HPS, dataCut)
freqArray = []
dataCutCris, freqArray = fcts.garderUniquementCris(samplerate,0.5,1.5,250,450,f0.freq_from_HPS, dataCut)
for i in range(len(dataCutCris)):
fcts.aff("cri"+str(i), t, np.asarray(dataCutCris[i]))
#fcts.aff("cri"+str(i), t, np.asarray(dataCutCris[i]))
fcts.listen("output/cri"+str(i)+".wav", samplerate, np.asarray(dataCutCris[i]))
print("enregistrement: " + str(i))
print(np.round(f0.freq_from_HPS(np.asarray(dataCutCris[i]),samplerate)))
freqArray.append(f0.freq_from_HPS(np.asarray(dataCutCris[i]),samplerate))
print(np.round(freqArray[i]))
print("________________")
print(np.mean(freqArray))
......
......@@ -9,7 +9,7 @@ Created on Thu Mar 25 10:04:06 2021
from scipy.io import wavfile
import matplotlib.pyplot as plt
import numpy as np
import frequency_estimator.frequency_estimator as f0
import frequency_estimator as f0
def listen(nom,sampleRate, data):
......@@ -54,13 +54,15 @@ def garderUniquementCris(sampleRate,tMin, tMax, fMin, fMax, f0Func, dataCut):
nSamplesMin = tMin*sampleRate
nSamplesMax = tMax*sampleRate
res=[]
freqs=[]
for i in range(len(dataCut)):
if((len(dataCut[i])>nSamplesMin) & (len(dataCut[i])<nSamplesMax)):
freq = np.round(f0Func(np.asarray(dataCut[i]),sampleRate))
if((freq>fMin) & (freq<fMax)):
res.append(dataCut[i])
freqs.append(freq)
return res
return res, freqs
......
......@@ -9,7 +9,7 @@ try:
except ImportError:
from scikits.audiolab import flacread
from frequency_estimator.parabolic import parabolic
from parabolic import parabolic
def freq_from_crossings(sig, fs):
......
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