librosa

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,

“No Backend Error” while reading files in Python

最后都变了- 提交于 2020-02-07 05:30:44
问题 I am trying to perform STFT on a bunch of sound files and I get this error. The path of the files which I am trying to perform STFT is correct but still, I get this error. import librosa import io import numpy as np import tensorflow as tf import os import glob path_te = "C:\Users\aanum\OneDrive\Documents\Deep Learning\timit-homework\te" files = os.listdir(path_te) for file in sorted(files): if file.startswith("tex"): file_path = path_te2 + "/" + file #file_path = 'r' + "'" + str(file_path) +

Isolating audio foreground and converting back to audio stream using librosa

时间秒杀一切 提交于 2020-02-06 09:07:57
问题 I'm trying to isolate the foreground of an audio stream and then save it as a standalone audio stream using librosa. Starting with this seemingly relevant example. I have the full, foreground and background data isolated as the example does in S_full , S_foreground and S_background but I'm unsure as to what to do to use those as audio. I attempted to use librosa.istft(...) to convert those and then save that as a .wav file using soundfile.write(...) but I'm left with a file of roughly the

Librosa melspectrogram times don't match actual times in audio file

时间秒杀一切 提交于 2020-01-25 07:20:10
问题 I'm trying to calculate MFCC coefficients using librosa.feature, but when I plot it using specshow, times on the specshow graph don't match the actual times in my audio file I tried the code from librosa docs https://librosa.github.io/librosa/generated/librosa.feature.mfcc.html where we create MFCC having pre-computed log-power Mel spectrogram WINDOW_HOP = 0.01 # [sec] WINDOW_SIZE = 0.025 # [sec] y, fs = librosa.load('audio_dataset/0f39OWEqJ24.wav', sr=None) # fs is 22000 # according to

librosa: installs properly only with clone git AND cannot use any functions though it imports

回眸只為那壹抹淺笑 提交于 2020-01-24 22:45:13
问题 I'm quite a newbie with python, and programming in general, and I am currently struggling with installing and using the library librosa. I thought I succeeded installing it with: git clone https://github.com/librosa/librosa.git librosa and also with installing numpy and scipy seperately, again with: git clone https://github.com/numpy/numpy.git numpy git clone https://github.com/scipy/scipy.git scipy and it seemed to finally work. I could also: import librosa without any problems, but as I

RuntimeError: cannot cache function '__jaccard': no locator available for file '/usr/local/lib/python3.7/site-packages/librosa/util/matching.py'

此生再无相见时 提交于 2020-01-24 04:07:18
问题 I am dockerising the flask application on windows10 machine.I get the below error after the docker run RuntimeError: cannot cache function '__jaccard': no locator available for file '/usr/local/lib/python3.7/site-packages/librosa/util/matching.py' The flask application runs fine locally on my machine. i referred to kind of similar post: numba caching issue: cannot cache function / no locator available for file i have added the user access permissions for the application in the Dockerfile. 1.

Return value of librosa.effect.Split is strange

北慕城南 提交于 2020-01-14 19:08:46
问题 As titled, the result of this function is not logical and I don't understand what the function is doing. For example, here is some reproducible code: #load sample audio filename = librosa.util.example_audio_file() audio, sr = librosa.load(filename) #get intervals which are non-silent inter_20 = librosa.effects.split(audio, top_db=20) #audio above 20dB inter_5 = librosa.effects.split(audio, top_db=5) #audio above 5dB #create audio above_20 = np.zeros(audio.shape) above_5 = np.zeros(audio.shape

Return value of librosa.effect.Split is strange

我的梦境 提交于 2020-01-14 19:08:32
问题 As titled, the result of this function is not logical and I don't understand what the function is doing. For example, here is some reproducible code: #load sample audio filename = librosa.util.example_audio_file() audio, sr = librosa.load(filename) #get intervals which are non-silent inter_20 = librosa.effects.split(audio, top_db=20) #audio above 20dB inter_5 = librosa.effects.split(audio, top_db=5) #audio above 5dB #create audio above_20 = np.zeros(audio.shape) above_5 = np.zeros(audio.shape