mirror of
https://github.com/YuzuZensai/spleeter.git
synced 2026-01-06 04:32:43 +00:00
Add an option allowing use without a multiprocessing pool...
...this allows spleeter itself to be run asynchronously from another process using multiprocessing, which otherwise fails with "daemonic processes are not allowed to have children"
This commit is contained in:
@@ -35,7 +35,7 @@ __license__ = 'MIT License'
|
||||
class Separator(object):
|
||||
""" A wrapper class for performing separation. """
|
||||
|
||||
def __init__(self, params_descriptor, MWF=False):
|
||||
def __init__(self, params_descriptor, MWF=False, multiprocess=True):
|
||||
""" Default constructor.
|
||||
|
||||
:param params_descriptor: Descriptor for TF params to be used.
|
||||
@@ -45,7 +45,7 @@ class Separator(object):
|
||||
self._sample_rate = self._params['sample_rate']
|
||||
self._MWF = MWF
|
||||
self._predictor = None
|
||||
self._pool = Pool()
|
||||
self._pool = Pool() if multiprocess else None
|
||||
self._tasks = []
|
||||
|
||||
def _get_predictor(self):
|
||||
@@ -133,12 +133,15 @@ class Separator(object):
|
||||
f'Separated source path conflict : {path},'
|
||||
'please check your filename format'))
|
||||
generated.append(path)
|
||||
task = self._pool.apply_async(audio_adapter.save, (
|
||||
path,
|
||||
data,
|
||||
self._sample_rate,
|
||||
codec,
|
||||
bitrate))
|
||||
self._tasks.append(task)
|
||||
if synchronous:
|
||||
if self._pool:
|
||||
task = self._pool.apply_async(audio_adapter.save, (
|
||||
path,
|
||||
data,
|
||||
self._sample_rate,
|
||||
codec,
|
||||
bitrate))
|
||||
self._tasks.append(task)
|
||||
else:
|
||||
audio_adapter.save(path, data, self._sample_rate, codec, bitrate)
|
||||
if synchronous and self._pool:
|
||||
self.join()
|
||||
|
||||
Reference in New Issue
Block a user