问题描述
我正在尝试对一堆声音文件执行 STFT,但出现此错误.我尝试执行 STFT 的文件路径是正确的,但仍然出现此错误.
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) + "'"
print(file_path)
st, sr=librosa.load(file_path, sr=None)
输出:
C:/Users/aanum/OneDrive/Documents/Deep Learning/timit-homework/te/tex0000.wav
---------------------------------------------------------------------------
NoBackendError Traceback (most recent call last)
<ipython-input-54-4df25548d204> in <module>
7 #file_path = 'r' + "'" + str(file_path) + "'"
8 print(file_path)
----> 9 st, sr=librosa.load(file_path, sr=None)
10 X=librosa.stft(st, n_fft=1024, hop_length=512)
11 X_abs = abs(X)
~\Anaconda3\envs\DeepLearning\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
117
118 y = []
--> 119 with audioread.audio_open(os.path.realpath(path)) as input_file:
120 sr_native = input_file.samplerate
121 n_channels = input_file.channels
~\Anaconda3\envs\DeepLearning\lib\site-packages\audioread\__init__.py in audio_open(path, backends)
114
115 # All backends failed!
--> 116 raise NoBackendError()
NoBackendError
谁能告诉我为什么会出现这个错误?
Can anyone tell me why I have this error?
推荐答案
确保您的 .wav
文件没有损坏.您可以使用音频文件阅读器(可以读取 wav 文件)打开文件吗?如果没有,则您的文件已损坏.如果您从开源数据集中下载了音频文件,则在您手动解压缩文件夹时它们可能已损坏.我建议您再次下载数据集并使用命令行工具将其解压缩.
Make sure that your .wav
file is not corrupted. Can you open the file with an audio file reader (which can read wav files)? If not, your file is corrupted. If you downloaded the audio files from an opensource dataset, it is possible that they are corrupted while you are manually unzipping the folder. I'd recommend you download the dataset again and unzip it with a command-line tool.
这篇关于“无后端错误"在 Python 中读取文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!