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 crash MacOS because of multiprocessing fork #133

Open
wants to merge 5 commits into
base: master
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
10 changes: 10 additions & 0 deletions autosub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ def generate_subtitles( # pylint: disable=too-many-locals,too-many-arguments
"""
Given an input audio/video file, generate subtitles in the specified language and format.
"""
if os.name != "nt" and "Darwin" in os.uname():
#the default unix fork method does not work on Mac OS
#need to use forkserver
try:
if 'forkserver' not in multiprocessing.get_start_method(allow_none=True):
multiprocessing.set_start_method('forkserver')
except AttributeError:
# for python 2 not have set_start_method... cannot be used on mac
print("Python 2 fork() does not work on MacOS. Please use Python 3 instead.")

audio_filename, audio_rate = extract_audio(source_path)

regions = find_speech_regions(audio_filename)
Expand Down