As part of my school project, I recorded a wav file and am trying to analyze the file to get the amplitude , min frequency, standard deviation etc . I did the below in Python but the numbers are off
I get the below. The SD is more than the max. Also, human voice cant be this high frequency ( no background) . Any suggestions ?
Maximum Frequency: 263.0 Hz
Maximum Amplitude: 944.6695556640625
Median Frequency: 5512.454545454546 Hz
Mean Frequency: 5512.454545454545 Hz
Standard Deviation of Frequencies: 3182.643358799615 Hz
_____________________________________________________________________
import librosa
import numpy as np
# Specify the path to the audio file
audio_file = ‘clip.wav’
# Load the audio file
y, sr = librosa.load(audio_file)
# Compute the Short-Time Fourier Transform (STFT)
D = np.abs(librosa.stft(y))
# Convert amplitude to decibels
DB = librosa.amplitude_to_db(D, ref=np.max)
# Get the frequency and time bins
frequencies = librosa.fft_frequencies(sr=sr)
times = librosa.frames_to_time(np.arange(D.shape[1]), sr=sr)
# Calculate the maximum frequency and amplitude
max_amp_index = np.unravel_index(np.argmax(DB, axis=None), DB.shape)
max_freq = frequencies[max_amp_index[0]]
max_amplitude = DB[max_amp_index]
max_time = times[max_amp_index[1]]
# Calculate the median frequency
median_freq = np.median(frequencies)
# Calculate the mean frequency
mean_freq = np.mean(frequencies)
# Calculate the standard deviation of frequencies
std_freq = np.std(frequencies)
print(f’Maximum Frequency: {max_freq} Hz’)
print(f’Maximum Amplitude: {max_amplitude} dB’)
print(f’Time at Maximum Amplitude: {max_time} seconds’)
print(f’Median Frequency: {median_freq} Hz’)
print(f’Mean Frequency: {mean_freq} Hz’)
print(f’Standard Deviation of Frequencies: {std_freq} Hz’)
submitted by /u/Keypass1236
[link] [comments]
r/learnpython As part of my school project, I recorded a wav file and am trying to analyze the file to get the amplitude , min frequency, standard deviation etc . I did the below in Python but the numbers are off I get the below. The SD is more than the max. Also, human voice cant be this high frequency ( no background) . Any suggestions ? Maximum Frequency: 263.0 Hz Maximum Amplitude: 944.6695556640625 Median Frequency: 5512.454545454546 Hz Mean Frequency: 5512.454545454545 Hz Standard Deviation of Frequencies: 3182.643358799615 Hz _____________________________________________________________________ import librosa import numpy as np # Specify the path to the audio file audio_file = ‘clip.wav’ # Load the audio file y, sr = librosa.load(audio_file) # Compute the Short-Time Fourier Transform (STFT) D = np.abs(librosa.stft(y)) # Convert amplitude to decibels DB = librosa.amplitude_to_db(D, ref=np.max) # Get the frequency and time bins frequencies = librosa.fft_frequencies(sr=sr) times = librosa.frames_to_time(np.arange(D.shape[1]), sr=sr) # Calculate the maximum frequency and amplitude max_amp_index = np.unravel_index(np.argmax(DB, axis=None), DB.shape) max_freq = frequencies[max_amp_index[0]] max_amplitude = DB[max_amp_index] max_time = times[max_amp_index[1]] # Calculate the median frequency median_freq = np.median(frequencies) # Calculate the mean frequency mean_freq = np.mean(frequencies) # Calculate the standard deviation of frequencies std_freq = np.std(frequencies) print(f’Maximum Frequency: {max_freq} Hz’) print(f’Maximum Amplitude: {max_amplitude} dB’) print(f’Time at Maximum Amplitude: {max_time} seconds’) print(f’Median Frequency: {median_freq} Hz’) print(f’Mean Frequency: {mean_freq} Hz’) print(f’Standard Deviation of Frequencies: {std_freq} Hz’) submitted by /u/Keypass1236 [link] [comments]
As part of my school project, I recorded a wav file and am trying to analyze the file to get the amplitude , min frequency, standard deviation etc . I did the below in Python but the numbers are off
I get the below. The SD is more than the max. Also, human voice cant be this high frequency ( no background) . Any suggestions ?
Maximum Frequency: 263.0 Hz
Maximum Amplitude: 944.6695556640625
Median Frequency: 5512.454545454546 Hz
Mean Frequency: 5512.454545454545 Hz
Standard Deviation of Frequencies: 3182.643358799615 Hz
_____________________________________________________________________
import librosa
import numpy as np
# Specify the path to the audio file
audio_file = ‘clip.wav’
# Load the audio file
y, sr = librosa.load(audio_file)
# Compute the Short-Time Fourier Transform (STFT)
D = np.abs(librosa.stft(y))
# Convert amplitude to decibels
DB = librosa.amplitude_to_db(D, ref=np.max)
# Get the frequency and time bins
frequencies = librosa.fft_frequencies(sr=sr)
times = librosa.frames_to_time(np.arange(D.shape[1]), sr=sr)
# Calculate the maximum frequency and amplitude
max_amp_index = np.unravel_index(np.argmax(DB, axis=None), DB.shape)
max_freq = frequencies[max_amp_index[0]]
max_amplitude = DB[max_amp_index]
max_time = times[max_amp_index[1]]
# Calculate the median frequency
median_freq = np.median(frequencies)
# Calculate the mean frequency
mean_freq = np.mean(frequencies)
# Calculate the standard deviation of frequencies
std_freq = np.std(frequencies)
print(f’Maximum Frequency: {max_freq} Hz’)
print(f’Maximum Amplitude: {max_amplitude} dB’)
print(f’Time at Maximum Amplitude: {max_time} seconds’)
print(f’Median Frequency: {median_freq} Hz’)
print(f’Mean Frequency: {mean_freq} Hz’)
print(f’Standard Deviation of Frequencies: {std_freq} Hz’)
submitted by /u/Keypass1236
[link] [comments]