Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,7 @@ pretrained_models
docs/build
.vscode
spleeter-feedstock/
*FAKE_MUSDB_DIR
*FAKE_MUSDB_DIR

output/
useless_config.json
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog History

## 2.4.2

Dependecy upgrades and adding support for python 3.11 (dropping 3.7)

## 2.3.2

Release contrain on specific Tensorflow, numpy and Librosa versions
Expand Down
2,257 changes: 1,280 additions & 977 deletions poetry.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spleeter"
version = "2.4.1"
version = "2.4.2"
description = "The Deezer source separation library with pretrained models based on tensorflow."
authors = ["Deezer Research <spleeter@deezer.com>"]
license = "MIT License"
Expand All @@ -21,10 +21,10 @@ classifiers = [
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Artistic Software",
Expand All @@ -45,13 +45,14 @@ packages = [ { include = "spleeter" } ]
include = ["LICENSE", "spleeter/resources/*.json"]

[tool.poetry.dependencies]
python = ">=3.7.1,<3.11"
python = ">=3.8,<3.12"
ffmpeg-python = "^0.2.0"
httpx = {extras = ["http2"], version = "^0.19.0"}
typer = "^0.3.2"
musdb = {version = "^0.4.0", optional = true}
museval = {version = "^0.4.0", optional = true}
tensorflow = "^2.5.0, <2.10.0"
tensorflow-io-gcs-filesystem = "0.32.0"
tensorflow = "2.12.1"
pandas = "^1.3.0"
norbert = "^0.2.1"
numpy = "<2.0.0"
Expand All @@ -60,7 +61,7 @@ numpy = "<2.0.0"
pytest = "^6.2.1"
isort = "^5.7.0"
black = "^21.7b0"
mypy = "^0.790"
mypy = ">0.790,<1.0"
flake8 = "^5.0.0"
pytest-forked = "^1.3.0"
musdb = "^0.4.0"
Expand Down
13 changes: 11 additions & 2 deletions spleeter/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@
- Waveform convertion and transforming functions.
"""

from enum import Enum
# Python 3.11 is not backward compatible for String Enum
# https://tomwojcik.com/posts/2023-01-02/python-311-str-enum-breaking-change
try:
from enum import StrEnum
except ImportError:
from enum import Enum

class StrEnum(str, Enum):
pass


__email__ = "spleeter@deezer.com"
__author__ = "Deezer Research"
__license__ = "MIT License"


class Codec(str, Enum):
class Codec(StrEnum):
"""Enumeration of supported audio codec."""

WAV: str = "wav"
Expand Down
50 changes: 9 additions & 41 deletions spleeter/separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,6 @@
__license__ = "MIT License"


class DataGenerator(object):
"""
Generator object that store a sample and generate it once while called.
Used to feed a tensorflow estimator without knowing the whole data at
build time.
"""

def __init__(self) -> None:
"""Default constructor."""
self._current_data = None

def update_data(self, data) -> None:
"""Replace internal data."""
self._current_data = data

def __call__(self) -> Generator:
"""Generation process."""
buffer = self._current_data
while buffer:
yield buffer
buffer = self._current_data


def create_estimator(params: Dict, MWF: bool) -> tf.Tensor:
"""
Initialize tensorflow estimator that will perform separation
Expand Down Expand Up @@ -128,9 +105,9 @@ def __init__(
else:
self._pool = None
self._tasks: List = []
self._data_generator = DataGenerator()
self.estimator = None

def _get_prediction_generator(self) -> Generator:
def _get_prediction_generator(self, data: dict) -> Generator:
"""
Lazy loading access method for internal prediction generator
returned by the predict method of a tensorflow estimator.
Expand All @@ -139,20 +116,13 @@ def _get_prediction_generator(self) -> Generator:
Generator:
Generator of prediction.
"""
if self._prediction_generator is None:
estimator = create_estimator(self._params, self._MWF)

def get_dataset():
return tf.data.Dataset.from_generator(
self._data_generator,
output_types={"waveform": tf.float32, "audio_id": tf.string},
output_shapes={"waveform": (None, 2), "audio_id": ()},
)
if not self.estimator:
self.estimator = create_estimator(self._params, self._MWF)

self._prediction_generator = estimator.predict(
get_dataset, yield_single_examples=False
)
return self._prediction_generator
def get_dataset():
return tf.data.Dataset.from_tensors(data)

return self.estimator.predict(get_dataset, yield_single_examples=False)

def join(self, timeout: int = 200) -> None:
"""
Expand Down Expand Up @@ -212,9 +182,7 @@ def _separate_tensorflow(
"""
if not waveform.shape[-1] == 2:
waveform = to_stereo(waveform)
prediction_generator = self._get_prediction_generator()
# NOTE: update data in generator before performing separation.
self._data_generator.update_data(
prediction_generator = self._get_prediction_generator(
{"waveform": waveform, "audio_id": np.array(audio_descriptor)}
)
# NOTE: perform separation.
Expand Down
Loading