diff --git a/platypush/plugins/sound/_streams/_player/_synth/_base.py b/platypush/plugins/sound/_streams/_player/_synth/_base.py index 7b1d13c9a6..fee3def984 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_base.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_base.py @@ -2,7 +2,6 @@ from abc import ABC, abstractmethod from typing import Optional, Tuple import numpy as np -from numpy.typing import NDArray from ._parser import SoundParser @@ -31,7 +30,7 @@ class SoundBase(SoundParser, ABC): t_start: float = 0, t_end: float = 0, **_, - ) -> NDArray[np.floating]: + ): # -> NDArray[np.floating]: """ Get the wave binary data associated to this sound @@ -50,7 +49,7 @@ class SoundBase(SoundParser, ABC): t_end: float = 0.0, freq_range: Optional[Tuple[float, float]] = None, freq_buckets: Optional[int] = None, - ) -> NDArray[np.floating]: + ): # -> NDArray[np.floating]: """ Get the real part of the Fourier transform associated to a time-bounded sample of this sound. diff --git a/platypush/plugins/sound/_streams/_player/_synth/_generator.py b/platypush/plugins/sound/_streams/_player/_synth/_generator.py index 22bc60fc5b..36be584b1a 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_generator.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_generator.py @@ -4,9 +4,6 @@ from threading import Thread from time import time from typing import Any, Callable, Optional -import numpy as np -from numpy.typing import NDArray - from ._mix import Mix @@ -20,7 +17,7 @@ class AudioGenerator(Thread): def __init__( self, *args, - audio_queue: Queue[NDArray[np.number]], + audio_queue: Queue, # Queue[NDArray[np.number]], mix: Mix, blocksize: int, sample_rate: int, diff --git a/platypush/plugins/sound/_streams/_player/_synth/_mix.py b/platypush/plugins/sound/_streams/_player/_synth/_mix.py index 957a208484..355f64d8d0 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_mix.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_mix.py @@ -3,7 +3,6 @@ import logging from typing import List, Tuple, Union import numpy as np -from numpy.typing import DTypeLike, NDArray from ...._utils import convert_nd_array from ._base import SoundBase @@ -16,7 +15,7 @@ class Mix(SoundBase): through an audio stream to an audio device """ - def __init__(self, *sounds, channels: int, dtype: DTypeLike, **kwargs): + def __init__(self, *sounds, channels: int, dtype, **kwargs): super().__init__(**kwargs) self._sounds: List[Sound] = [] self.logger = logging.getLogger(__name__) @@ -64,7 +63,7 @@ class Mix(SoundBase): normalize_range: Tuple[float, float] = (-1.0, 1.0), on_clip: str = 'scale', **_, - ) -> NDArray[np.number]: + ): # -> NDArray[np.number]: wave = None for sound in self._sounds: diff --git a/platypush/plugins/sound/_streams/_player/_synth/_output.py b/platypush/plugins/sound/_streams/_player/_synth/_output.py index d2743f2dba..1f6ba5aa94 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_output.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_output.py @@ -4,9 +4,6 @@ from typing import Callable, Optional import sounddevice as sd -import numpy as np -from numpy.typing import NDArray - # pylint: disable=too-few-public-methods class AudioOutputCallback: @@ -18,7 +15,7 @@ class AudioOutputCallback: def __init__( self, *args, - audio_queue: Queue[NDArray[np.number]], + audio_queue: Queue, # Queue[NDArray[np.number]], channels: int, blocksize: int, should_stop: Callable[[], bool] = lambda: False, @@ -50,7 +47,8 @@ class AudioOutputCallback: assert not status.output_underflow, 'Output underflow: increase blocksize?' assert not status, f'Audio callback failed: {status}' - def _audio_callback(self, outdata: NDArray[np.number], frames: int, status): + # outdata: NDArray[np.number] + def _audio_callback(self, outdata, frames: int, status): if self._is_paused(): return @@ -72,7 +70,8 @@ class AudioOutputCallback: outdata[:audio_length] = data[:audio_length] # _ = time - def __call__(self, outdata: NDArray[np.number], frames: int, _, status): + # outdata: NDArray[np.number] + def __call__(self, outdata, frames: int, _, status): try: self._audio_callback(outdata, frames, status) except AssertionError as e: diff --git a/platypush/plugins/sound/_streams/_player/_synth/_player.py b/platypush/plugins/sound/_streams/_player/_synth/_player.py index c0d6b10999..0ef6981143 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_player.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_player.py @@ -3,9 +3,7 @@ from queue import Queue from threading import Event from typing import Any, Generator, Iterable, Optional, Type -import numpy as np import sounddevice as sd -from numpy.typing import DTypeLike, NDArray from ...._model import AudioState from ..._player import AudioPlayer @@ -26,7 +24,7 @@ class AudioSynthPlayer(AudioPlayer): *args, volume: float, channels: int, - dtype: DTypeLike, + dtype, # : DTypeLike, sounds: Optional[Iterable[Sound]] = None, **kwargs ): @@ -36,7 +34,7 @@ class AudioSynthPlayer(AudioPlayer): super().__init__(*args, volume=volume, channels=channels, dtype=dtype, **kwargs) self._generator_stopped = Event() self._completed_callback_event = Event() - self._audio_queue: Queue[NDArray[np.number]] = Queue( + self._audio_queue = Queue( # Queue[NDArray[np.number]] maxsize=self.queue_size or 0 ) diff --git a/platypush/plugins/sound/_streams/_player/_synth/_sound.py b/platypush/plugins/sound/_streams/_player/_synth/_sound.py index 270dcc5b65..cf8487a6fc 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_sound.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_sound.py @@ -1,9 +1,8 @@ from enum import Enum import json -from typing import Final, Optional, Tuple, Union +from typing import Final, Optional, Union import numpy as np -from numpy.typing import NDArray from ._base import SoundBase @@ -103,7 +102,7 @@ class Sound(SoundBase): def _get_audio_pad( self, sample_rate: float, t_start: float, t_end: float - ) -> Tuple[NDArray[np.floating], NDArray[np.floating]]: + ): # -> Tuple[NDArray[np.floating], NDArray[np.floating]]: """ Return the left and right audio pads for a given audio length as a ``(left, right)`` tuple of numpy zero-filled arrays. @@ -120,7 +119,7 @@ class Sound(SoundBase): ) ) - def _generate_wave(self, x: NDArray[np.floating]): + def _generate_wave(self, x): """ Generate a raw audio wave as a numpy array of floating between -1 and 1 given ``x`` as a set of timestamp samples. @@ -149,7 +148,7 @@ class Sound(SoundBase): t_start: float = 0, t_end: float = 0, **_, - ) -> NDArray[np.floating]: + ): # -> NDArray[np.floating]: """ Get the wave binary data associated to this sound diff --git a/platypush/plugins/sound/_utils/_convert.py b/platypush/plugins/sound/_utils/_convert.py index fa27fe510e..89b6159fab 100644 --- a/platypush/plugins/sound/_utils/_convert.py +++ b/platypush/plugins/sound/_utils/_convert.py @@ -1,10 +1,7 @@ import numpy as np -from numpy.typing import DTypeLike, NDArray -def convert_nd_array( # pylint: disable=too-many-return-statements - wave: NDArray[np.floating], dtype: DTypeLike -) -> NDArray[np.number]: +def convert_nd_array(wave, dtype): # pylint: disable=too-many-return-statements """ Given a wave as a series of floating point numbers, convert them to the appropriate data type.