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

Fix error when run ffmpeg on Windows #74

Merged
merged 2 commits into from
Oct 21, 2017
Merged
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
8 changes: 4 additions & 4 deletions bin/autosub
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class FLACConverter(object):
command = ["ffmpeg","-ss", str(start), "-t", str(end - start),
"-y", "-i", self.source_path,
"-loglevel", "error", temp.name]
subprocess.check_output(command, stdin=open(os.devnull))
use_shell = True if os.name == "nt" else False
subprocess.check_output(command, stdin=open(os.devnull), shell=use_shell)
return temp.read()

except KeyboardInterrupt:
Expand Down Expand Up @@ -139,7 +140,8 @@ def extract_audio(filename, channels=1, rate=16000):
print "ffmpeg: Executable not found on machine."
raise Exception("Dependency not found: ffmpeg")
command = ["ffmpeg", "-y", "-i", filename, "-ac", str(channels), "-ar", str(rate), "-loglevel", "error", temp.name]
subprocess.check_output(command, stdin=open(os.devnull))
use_shell = True if os.name == "nt" else False
subprocess.check_output(command, stdin=open(os.devnull), shell=use_shell)
return temp.name, rate


Expand All @@ -148,8 +150,6 @@ def find_speech_regions(filename, frame_width=4096, min_region_size=0.5, max_reg
sample_width = reader.getsampwidth()
rate = reader.getframerate()
n_channels = reader.getnchannels()

total_duration = reader.getnframes() / rate
chunk_duration = float(frame_width) / rate

n_chunks = int(math.ceil(reader.getnframes()*1.0 / frame_width))
Expand Down