Commit 3c3ce998 authored by Jeremy Howard's avatar Jeremy Howard Committed by Soumith Chintala
Browse files

stringify filename on load for compatibility with pathlib

parent 8b616bce
...@@ -26,7 +26,7 @@ def load(filepath, ...@@ -26,7 +26,7 @@ def load(filepath,
"""Loads an audio file from disk into a Tensor """Loads an audio file from disk into a Tensor
Args: Args:
filepath (string): path to audio file filepath (string or pathlib.Path): path to audio file
out (Tensor, optional): an output Tensor to use instead of creating one out (Tensor, optional): an output Tensor to use instead of creating one
normalization (bool, number, or callable, optional): If boolean `True`, then output is divided by `1 << 31` normalization (bool, number, or callable, optional): If boolean `True`, then output is divided by `1 << 31`
(assumes signed 32-bit audio), and normalizes to `[0, 1]`. (assumes signed 32-bit audio), and normalizes to `[0, 1]`.
...@@ -60,6 +60,8 @@ def load(filepath, ...@@ -60,6 +60,8 @@ def load(filepath,
1. 1.
""" """
# stringify if `pathlib.Path` (noop if already `str`)
filepath = str(filepath)
# check if valid file # check if valid file
if not os.path.isfile(filepath): if not os.path.isfile(filepath):
raise OSError("{} not found or is a directory".format(filepath)) raise OSError("{} not found or is a directory".format(filepath))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment