-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
soundfile.LibsndfileError: <exception str() failed> #428
Comments
Please post a concise problem description. We are not here to debug your code, but merely to discuss issues with python-soundfile. Something inside torch seems to be eating the LibsndfileError message. Without that message, there's not much we can do. |
Apologize, I am still a begineer in here, so I was confuse what to write, so I use .wav file, and then I run code from https://github.com/claritychallenge/clarity/tree/main/recipes/cec1/e009_sheffield but i got error message like this soundfile.LibsndfileError: <exception str() failed> (before i can use mu gpu) and got soundfile.LibsndfileError: (after i can use my gpu) for the same code. |
I also met the same question.Do you solve it? |
As I said, without the error message there's not much we can do. Grab your debugger, dig out that error message. |
the error message is like what I write (soundfile.LibsndfileError: <exception str() failed> and soundfile.LibsndfileError: ). I don't know what error message do you referes to? |
"exception str() failed" means that torch is trying to convert the LibsndfileError to a string, which fails. That LibsndfileError, however, does hold the real error message, which torch drops at that point. But without that message, we don't know what went wrong. |
I use this code in windows
import json
import logging
from pathlib import Path
import hydra
import numpy as np
import pytorch_lightning as pl
import torch
import torchaudio
from omegaconf import DictConfig
from pytorch_lightning.callbacks import ModelCheckpoint
from torch.utils.data import DataLoader
from clarity.dataset.cec1_dataset import CEC1Dataset
from clarity.engine.losses import SNRLoss, STOILevelLoss
from clarity.engine.system import System
from clarity.enhancer.dnn.mc_conv_tasnet import ConvTasNet
from clarity.enhancer.dsp.filter import AudiometricFIR
from clarity.predictor.torch_msbg import MSBGHearingModel
logger = logging.getLogger(name)
class DenModule(System):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
self.ear_idx = None
self.down_sample = None
class AmpModule(System):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
self.hl_ear = None
self.nh_ear = None
self.down_sample = None
self.up_sample = None
self.ear_idx = None
self.den_model = None
def train_den(cfg, ear):
exp_dir = Path(cfg.path.exp_folder) / f"{ear}_den"
if (exp_dir / "best_model.pth").exists():
logger.info("Enhancement module exist")
return
def train_amp(cfg, ear):
exp_dir = Path(cfg.path.exp_folder) / f"{ear}_amp"
Path.mkdir(exp_dir, parents=True, exist_ok=True)
if (exp_dir / "best_model.pth").exists():
logger.info("Amplification module exist")
return
@hydra.main(config_path=".", config_name="config")
def run(cfg: DictConfig) -> None:
logger.info("Begin training left ear enhancement module.")
train_den(cfg, ear="left")
logger.info("Begin training right ear enhancement module.")
train_den(cfg, ear="right")
logger.info("Begin training left ear amplification module.")
train_amp(cfg, ear="left")
logger.info("Begin training right ear amplification module.")
train_amp(cfg, ear="right")
pylint: disable=no-value-for-parameter
if name == "main":
run()
and this is the code for cec1_dataset.py:
import json
import logging
from pathlib import Path
import librosa
import numpy as np
import torch
from scipy.signal import firwin, lfilter
from soundfile import read
from torch.utils import data
logger = logging.getLogger(name)
def read_wavfile(path):
wav, _ = read(path)
return wav.transpose()
class CEC1Dataset(data.Dataset):
def init(
self,
scenes_folder,
scenes_file,
sample_rate,
downsample_factor,
wav_sample_len=None,
wav_silence_len=2,
num_channels=6,
norm=False,
testing=False,
):
self.scenes_folder = scenes_folder
self.sample_rate = sample_rate
self.downsample_factor = downsample_factor
self.wav_sample_len = wav_sample_len
self.wav_silence_len = wav_silence_len
self.num_channels = num_channels
self.norm = norm
self.testing = testing
But i got this error, please help me (the file name is in wav)



The text was updated successfully, but these errors were encountered: