mirror of
https://github.com/YuzuZensai/spleeter.git
synced 2026-01-31 14:58:23 +00:00
🎨 fix types
This commit is contained in:
@@ -26,8 +26,10 @@ from . import SpleeterError
|
|||||||
from .audio import Codec, STFTBackend
|
from .audio import Codec, STFTBackend
|
||||||
from .audio.adapter import AudioAdapter
|
from .audio.adapter import AudioAdapter
|
||||||
from .audio.convertor import to_stereo
|
from .audio.convertor import to_stereo
|
||||||
from .model import EstimatorSpecBuilder, InputProviderFactory
|
|
||||||
from .model import model_fn
|
from .model import model_fn
|
||||||
|
from .model import EstimatorSpecBuilder, InputProviderFactory
|
||||||
|
from .model.provider import ModelProvider
|
||||||
|
from .types import AudioDescriptor
|
||||||
from .utils.configuration import load_configuration
|
from .utils.configuration import load_configuration
|
||||||
|
|
||||||
# pyright: reportMissingImports=false
|
# pyright: reportMissingImports=false
|
||||||
@@ -255,14 +257,14 @@ class Separator(object):
|
|||||||
def _separate_librosa(
|
def _separate_librosa(
|
||||||
self,
|
self,
|
||||||
waveform: np.ndarray,
|
waveform: np.ndarray,
|
||||||
audio_descriptor: str) -> Dict:
|
audio_descriptor: AudioDescriptor) -> Dict:
|
||||||
"""
|
"""
|
||||||
Performs separation with librosa backend for STFT.
|
Performs separation with librosa backend for STFT.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
waveform (numpy.ndarray):
|
waveform (numpy.ndarray):
|
||||||
Waveform to be separated (as a numpy array)
|
Waveform to be separated (as a numpy array)
|
||||||
audio_descriptor (str):
|
audio_descriptor (AudioDescriptor):
|
||||||
"""
|
"""
|
||||||
with self._tf_graph.as_default():
|
with self._tf_graph.as_default():
|
||||||
out = {}
|
out = {}
|
||||||
@@ -292,7 +294,7 @@ class Separator(object):
|
|||||||
def _separate_tensorflow(
|
def _separate_tensorflow(
|
||||||
self,
|
self,
|
||||||
waveform: np.ndarray,
|
waveform: np.ndarray,
|
||||||
audio_descriptor: str) -> Dict:
|
audio_descriptor: AudioDescriptor) -> Dict:
|
||||||
"""
|
"""
|
||||||
Performs source separation over the given waveform with tensorflow
|
Performs source separation over the given waveform with tensorflow
|
||||||
backend.
|
backend.
|
||||||
@@ -300,7 +302,7 @@ class Separator(object):
|
|||||||
Parameters:
|
Parameters:
|
||||||
waveform (numpy.ndarray):
|
waveform (numpy.ndarray):
|
||||||
Waveform to be separated (as a numpy array)
|
Waveform to be separated (as a numpy array)
|
||||||
audio_descriptor (str):
|
audio_descriptor (AudioDescriptor):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Separated waveforms.
|
Separated waveforms.
|
||||||
@@ -339,7 +341,7 @@ class Separator(object):
|
|||||||
|
|
||||||
def separate_to_file(
|
def separate_to_file(
|
||||||
self,
|
self,
|
||||||
audio_descriptor: str,
|
audio_descriptor: AudioDescriptor,
|
||||||
destination: str,
|
destination: str,
|
||||||
audio_adapter: Optional[AudioAdapter] = None,
|
audio_adapter: Optional[AudioAdapter] = None,
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
@@ -361,7 +363,7 @@ class Separator(object):
|
|||||||
- {codec}.
|
- {codec}.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
audio_descriptor (str):
|
audio_descriptor (AudioDescriptor):
|
||||||
Describe song to separate, used by audio adapter to
|
Describe song to separate, used by audio adapter to
|
||||||
retrieve and load audio data, in case of file based
|
retrieve and load audio data, in case of file based
|
||||||
audio adapter, such descriptor would be a file path.
|
audio adapter, such descriptor would be a file path.
|
||||||
@@ -403,7 +405,7 @@ class Separator(object):
|
|||||||
def save_to_file(
|
def save_to_file(
|
||||||
self,
|
self,
|
||||||
sources: Dict,
|
sources: Dict,
|
||||||
audio_descriptor: str,
|
audio_descriptor: AudioDescriptor,
|
||||||
destination: str,
|
destination: str,
|
||||||
filename_format: str = '{filename}/{instrument}.{codec}',
|
filename_format: str = '{filename}/{instrument}.{codec}',
|
||||||
codec: Codec = Codec.WAV,
|
codec: Codec = Codec.WAV,
|
||||||
@@ -419,7 +421,7 @@ class Separator(object):
|
|||||||
of the instruments, and the values are `N x 2` numpy arrays
|
of the instruments, and the values are `N x 2` numpy arrays
|
||||||
containing the corresponding intrument waveform, as
|
containing the corresponding intrument waveform, as
|
||||||
returned by the separate method
|
returned by the separate method
|
||||||
audio_descriptor (str):
|
audio_descriptor (AudioDescriptor):
|
||||||
Describe song to separate, used by audio adapter to
|
Describe song to separate, used by audio adapter to
|
||||||
retrieve and load audio data, in case of file based audio
|
retrieve and load audio data, in case of file based audio
|
||||||
adapter, such descriptor would be a file path.
|
adapter, such descriptor would be a file path.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding: utf8
|
# coding: utf8
|
||||||
|
|
||||||
""" TO DOCUMENT """
|
""" Custom types definition. """
|
||||||
|
|
||||||
from typing import Any, Tuple
|
from typing import Any, Tuple
|
||||||
|
|
||||||
@@ -10,6 +10,5 @@ from typing import Any, Tuple
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
# pylint: enable=import-error
|
# pylint: enable=import-error
|
||||||
|
|
||||||
|
|
||||||
AudioDescriptor: type = Any
|
AudioDescriptor: type = Any
|
||||||
Signal: type = Tuple[np.ndarray, float]
|
Signal: type = Tuple[np.ndarray, float]
|
||||||
|
|||||||
Reference in New Issue
Block a user