Skip to content

Convert pathlib objects to str when used as argument to librosa.load() #371

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

Merged
1 commit merged into from Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
# - Directly load from the filepath:
preprocessed_wav = encoder.preprocess_wav(in_fpath)
# - If the wav is already loaded:
original_wav, sampling_rate = librosa.load(in_fpath)
original_wav, sampling_rate = librosa.load(str(in_fpath))
preprocessed_wav = encoder.preprocess_wav(original_wav, sampling_rate)
print("Loaded file succesfully")

Expand Down
2 changes: 1 addition & 1 deletion encoder/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def preprocess_wav(fpath_or_wav: Union[str, Path, np.ndarray],
"""
# Load the wav from disk if needed
if isinstance(fpath_or_wav, str) or isinstance(fpath_or_wav, Path):
wav, source_sr = librosa.load(fpath_or_wav, sr=None)
wav, source_sr = librosa.load(str(fpath_or_wav), sr=None)
else:
wav = fpath_or_wav

Expand Down
2 changes: 1 addition & 1 deletion synthesizer/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def load_preprocess_wav(fpath):
Loads and preprocesses an audio file under the same conditions the audio files were used to
train the synthesizer.
"""
wav = librosa.load(fpath, hparams.sample_rate)[0]
wav = librosa.load(str(fpath), hparams.sample_rate)[0]
if hparams.rescale:
wav = wav / np.abs(wav).max() * hparams.rescaling_max
return wav
Expand Down
2 changes: 1 addition & 1 deletion synthesizer/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def preprocess_speaker(speaker_dir, out_dir: Path, skip_existing: bool, hparams)

def split_on_silences(wav_fpath, words, end_times, hparams):
# Load the audio waveform
wav, _ = librosa.load(wav_fpath, hparams.sample_rate)
wav, _ = librosa.load(str(wav_fpath), hparams.sample_rate)
if hparams.rescale:
wav = wav / np.abs(wav).max() * hparams.rescaling_max

Expand Down
2 changes: 1 addition & 1 deletion vocoder/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def float_2_label(x, bits) :


def load_wav(path) :
return librosa.load(path, sr=hp.sample_rate)[0]
return librosa.load(str(path), sr=hp.sample_rate)[0]


def save_wav(x, path) :
Expand Down