spectrogram

Can I convert spectrograms generated with librosa back to audio?

 ̄綄美尐妖づ 提交于 2020-05-15 06:38:27
问题 I converted some audio files to spectrograms and saved them to files using the following code: import os from matplotlib import pyplot as plt import librosa import librosa.display import IPython.display as ipd audio_fpath = "./audios/" spectrograms_path = "./spectrograms/" audio_clips = os.listdir(audio_fpath) def generate_spectrogram(x, sr, save_name): X = librosa.stft(x) Xdb = librosa.amplitude_to_db(abs(X)) fig = plt.figure(figsize=(20, 20), dpi=1000, frameon=False) ax = fig.add_axes([0, 0

How can I reverse a scipy.signal.spectrogram to audio with Python?

依然范特西╮ 提交于 2020-03-24 09:43:13
问题 I have: import librosa from scipy import signal import scipy.io.wavfile as sf samples, sample_rate = sf.read(args.file) nperseg = int(sample_rate * 0.001 * 20) frequencies, times, spectrogram = signal.spectrogram(samples, sample_rate, nperseg=nperseg, window=signal.hann(nperseg)) audio_signal = librosa.griffinlim(spectrogram) print(audio_signal, audio_signal.shape) sf.write('test.wav', audio_signal, sample_rate) However, this produces a (near) empty sound file. 回答1: As @DrSpill mentioned,

How can I reverse a scipy.signal.spectrogram to audio with Python?

折月煮酒 提交于 2020-03-24 09:43:04
问题 I have: import librosa from scipy import signal import scipy.io.wavfile as sf samples, sample_rate = sf.read(args.file) nperseg = int(sample_rate * 0.001 * 20) frequencies, times, spectrogram = signal.spectrogram(samples, sample_rate, nperseg=nperseg, window=signal.hann(nperseg)) audio_signal = librosa.griffinlim(spectrogram) print(audio_signal, audio_signal.shape) sf.write('test.wav', audio_signal, sample_rate) However, this produces a (near) empty sound file. 回答1: As @DrSpill mentioned,

Plotting with matplotlib specgram?

别来无恙 提交于 2020-01-23 03:35:07
问题 I'm trying to plot a signal and the spectrogram of the signal with matplotlib, but... i get the spectrogram only for the first value (samples) of my signal (like 60 of the 30000...). It's a very long file, that's why I would like to plot only the first 30000 sample. here is the code : import matplotlib.pyplot as plt import numpy as np import pandas as pd Data=pd.read_csv('MySignal.txt', skiprows=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19], header=0) print(Data.head()) DataI=Data['Sig'

scipy.signal.spectrogram nfft parameter

情到浓时终转凉″ 提交于 2020-01-21 05:48:05
问题 What does nfft parameter mean in this function? Please refer to this link for the documentation https://docs.scipy.org/doc/scipy-0.19.0/reference/generated/scipy.signal.spectrogram.html 回答1: scipy.signal.spectrogram works by splitting the signal into (partially overlapping) segments of time, and then computing the power spectrum from the Fast Fourier Transform (FFT) of each segment. The length of these segments can be controlled using the nperseg argument, which lets you adjust the trade-off

Creating wave data from FFT data?

萝らか妹 提交于 2020-01-16 19:39:58
问题 As you might notice, i am really new to python and sound processing. I (hopefully) extracted FFT data from a wave file using python and the logfbank and mfcc function. (The logfbank seems to give the most promising data, mfcc output looked a bit weird for me). In my program i want to change the logfbank/mfcc data and then create wave data from it (and write them into a file). I didn't really find any information about the process of creating wave data from FFT data. Does anyone of you have an

Can I adjust spectogram frequency axes?

情到浓时终转凉″ 提交于 2020-01-03 12:34:20
问题 The MATLAB documentation examples for the spectrogram function gives examples that have the frequency axis set to [0 500] . Can I change this to something like [0 100] ? Obviously running the axis command will do this for me, but that adjusts the end result and "blows up" the resultant plot, make it pixelated. I am basically looking to build a spectrogram that only looks for frequencies between 0-100, not rescaling after building the spectrogram. Here's an example from that documentation: T =

How to use a context window to segment a whole log Mel-spectrogram (ensuring the same number of segments for all the audios)?

筅森魡賤 提交于 2020-01-03 01:55:14
问题 I have several audios with different duration. So I don't know how to ensure the same number N of segments of the audio. I'm trying to implement an existing paper, so it's said that first a Log Mel-Spectrogram is performed in the whole audio with 64 Mel-filter banks from 20 to 8000 Hz, by using a 25 ms Hamming window and a 10 ms overlapping. Then, in order to get that I have the following code lines: y, sr = librosa.load(audio_file, sr=None) #sr = 22050 #len(y) = 237142 #duration = 5

How do I get the values of a specific frequency range

…衆ロ難τιáo~ 提交于 2019-12-24 20:35:04
问题 I have a .wav file, I load it and I get the next spectrogram showing the spectrum in dB http://i.stack.imgur.com/22TjY.png Now I would like to know these values exactly because I want to compare with other wav file, for recognizing if these 4 values are there. http://i.stack.imgur.com/Jun25.png The source to generate that pictures (taken from other stackoverflow example) ## some stuff here for i in range(0, int(RATE / CHUNK_SIZE * RECORD_SECONDS)): # little endian, signed shortdata_chunk data

How does Octave spectrogram 'specgram' from signal work?

只愿长相守 提交于 2019-12-24 17:39:27
问题 I'm trying to test the specgram function located in the signal package in Octave but I'm a little confused at the input/output variables for specgram. What I would like to do is be able to get the specgram data into an array that will show the frequency and the length of time when the frequency starts and stops. See example code below: I was trying to get the array to show that for the length of t1 it will be 7hz, t2 will be 12hz and for t3 will be 2hz. How can I go about doing this? I'm