spectrogram

Rendering a float array to 24-bit RGB image (using PIL for example)

醉酒当歌 提交于 2021-02-18 11:44:09
问题 x is a numpy.float32 array, with values from -200 to 0 . These are dB (decibel) values. When I do (as recommended here): Image.fromarray(x, mode='F') I get a greyscale or sometimes nearly black image. How to map a float in [-200, 0] to a 24-bit RGB byte array (using a colormap) that can be read with the Python module PIL with Image.fromarray(x, mode='RGB') ? Edit: The required .wav audio file is here, for which we want to plot the spectrogram. Here is some code to test: import scipy, numpy as

How do you determing the correct dimension of Mel Spectrogram Feature Extraction for NN

末鹿安然 提交于 2021-02-11 12:26:34
问题 I trying to implement a Mel Spectrogram feature extraction: n_mels = 128 # Extracting MelFrequency Spectrum for every file def extract_features(file_name): try: audio, sample_rate = librosa.load(file_name, res_type='kaiser_fast') mely = librosa.feature.melspectrogram(y=audio, sr=sample_rate, n_mels=n_mels) except Exception as e: print("Error encountered while parsing file: ", file) return None return mely.T It appears that I am implementing this feature extraction incorrectly as when I check

How do you determing the correct dimension of Mel Spectrogram Feature Extraction for NN

筅森魡賤 提交于 2021-02-11 12:25:38
问题 I trying to implement a Mel Spectrogram feature extraction: n_mels = 128 # Extracting MelFrequency Spectrum for every file def extract_features(file_name): try: audio, sample_rate = librosa.load(file_name, res_type='kaiser_fast') mely = librosa.feature.melspectrogram(y=audio, sr=sample_rate, n_mels=n_mels) except Exception as e: print("Error encountered while parsing file: ", file) return None return mely.T It appears that I am implementing this feature extraction incorrectly as when I check

How to convert a mel spectrogram to log-scaled mel spectrogram

耗尽温柔 提交于 2021-02-08 10:35:25
问题 I was reading this paper on environmental noise discrimination using Convolution Neural Networks and wanted to reproduce their results. They convert WAV files into log-scaled mel spectrograms. How do you do this? I am able to convert a WAV file to a mel spectrogram y, sr = librosa.load('audio/100263-2-0-117.wav',duration=3) ps = librosa.feature.melspectrogram(y=y, sr=sr) librosa.display.specshow(ps, y_axis='mel', x_axis='time') I am also able to display it as a log scaled spectrogram: librosa

How to convert a mel spectrogram to log-scaled mel spectrogram

跟風遠走 提交于 2021-02-08 10:31:01
问题 I was reading this paper on environmental noise discrimination using Convolution Neural Networks and wanted to reproduce their results. They convert WAV files into log-scaled mel spectrograms. How do you do this? I am able to convert a WAV file to a mel spectrogram y, sr = librosa.load('audio/100263-2-0-117.wav',duration=3) ps = librosa.feature.melspectrogram(y=y, sr=sr) librosa.display.specshow(ps, y_axis='mel', x_axis='time') I am also able to display it as a log scaled spectrogram: librosa

How to convert a seewave spectrogram into a wav file

假装没事ソ 提交于 2021-02-07 08:47:34
问题 I would like to manipulate a seewave audio spectrogram and then convert it back to a .wav file. A quick example library(tuneR) library(seewave) data(tico) #generate spectrogram with phase information spec_tico=spectro(tico,plot=FALSE,complex=TRUE,norm=FALSE,dB=NULL) #manipulate spectrogram spec_tico_new=dostuff(spec_tico) #convert back into Wave object - but there is no function spectr2Wave! tico_new=spectr2Wave(spec_tico_new,...) I haven't been able to find anything close to spectr2Wave in

Creating spectrogram from .wav using FFT in java

跟風遠走 提交于 2021-02-06 03:38:28
问题 After researching and a lot of trials-and-errors, I have come to a point that I can construct a spectrogram which I think it has element of rights and wrongs . 1. First, I read .wav file into a byte array and extract only the data part. 2. I convert the byte array into a double array which takes the average of right and left channels. I also notice that 1 sample of 1 channel consists of 2 bytes. So, 4 bytes into 1 double. 3. For a certain window size of power of 2, I apply FFT from here and

Python spectrogram in 3D (like matlab's spectrogram function)

与世无争的帅哥 提交于 2020-12-06 06:57:31
问题 My question is the following: I have all the values that I need for a spectrogram ( scipy.fftpack.fft ). I would like to create a 3D spectrogram in python. In MATLAB this is a very simple task, while in python it seems much more complicated. I tried mayavi, 3D plotting matplotlib but I have not managed to do this. Thanks My code: import numpy as np import pandas as pd import numpy as np from scipy import signal import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from

How can I improve the look of scipy's spectrograms?

♀尐吖头ヾ 提交于 2020-08-10 18:51:29
问题 I need to generate spectrograms for audio files with Python and I'm following the solution given here. However, the spectrograms I'm getting don't look very "populated," and not at all like other spectrograms I get from other software. This is the code I used for the particular image I'm showing here: import matplotlib.pyplot as plt from matplotlib import cm from scipy import signal from scipy.io import wavfile sample_rate, samples = wavfile.read('audio-mono.wav') frequencies, times,