justus-tobias commited on
Commit
4bc22ca
·
1 Parent(s): 02b192c

mean frequency was actually the the mean magnitude, now fixed

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. utils.py +4 -4
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ convert2freq.py
2
+ combined.csv
utils.py CHANGED
@@ -515,10 +515,10 @@ def segment_analysis(segment, sr, s1s2:list):
515
  # RMS Energy
516
  rms_energy = np.sqrt(np.mean(segment**2))
517
 
518
- # Frequencies
519
- # We'll use the mean of the magnitudes of the Fourier transform
520
- fft_magnitudes = np.abs(np.fft.rfft(segment))
521
- mean_frequency = np.mean(fft_magnitudes)
522
 
523
  s1_to_s2_duration = []
524
  s2_to_s1_duration = []
 
515
  # RMS Energy
516
  rms_energy = np.sqrt(np.mean(segment**2))
517
 
518
+ # Calculate actual mean frequency
519
+ fft = np.fft.rfft(segment)
520
+ freqs = np.fft.rfftfreq(len(segment), d=1/sr)
521
+ mean_frequency = np.mean(freqs)
522
 
523
  s1_to_s2_duration = []
524
  s2_to_s1_duration = []