Skip to content
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

Allow file-like objects for WavAudio.read_file #3

Open
wants to merge 1 commit into
base: kaldi
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions dragonfly/engines/backend_kaldi/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,11 @@ class WavAudio(object):
@classmethod
def read_file(cls, filename, realtime=False):
""" Yields raw audio blocks from wav file, terminated by a None element. """
if not os.path.isfile(filename):
raise IOError("'%s' is not a file. Please use a different file path.")
try:
if not os.path.isfile(filename):
raise IOError("'%s' is not a file. Please use a different file path.")
except TypeError:
pass # Allow file-like objects

with contextlib.closing(wave.open(filename, 'rb')) as file:
# Validate the wave file's header
Expand Down