pyquist 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyquist-0.2.1/pyquist.egg-info → pyquist-0.2.2}/PKG-INFO +1 -1
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/__init__.py +1 -1
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/device.py +8 -2
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/device_test.py +16 -1
- {pyquist-0.2.1 → pyquist-0.2.2/pyquist.egg-info}/PKG-INFO +1 -1
- {pyquist-0.2.1 → pyquist-0.2.2}/LICENSE +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/README.md +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyproject.toml +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/audio.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/audio_test.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/cli.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/helper.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/helper_test.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/paths.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/plot.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/plot_test.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/py.typed +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/score.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/score_test.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/test_data/232009__danmitch3ll__xylophone-sweep.wav +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/test_data/388954__fullmetaljedi__blues-riff-in-g-nylon.wav +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/test_data/434013__mrpearch__drum-patern.mp3 +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/test_data/ATTRIBUTION.md +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/test_data/ravel_bolero.mid +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/web/__init__.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/web/freesound.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist/web/theorytab.py +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist.egg-info/SOURCES.txt +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist.egg-info/dependency_links.txt +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist.egg-info/entry_points.txt +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist.egg-info/requires.txt +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/pyquist.egg-info/top_level.txt +0 -0
- {pyquist-0.2.1 → pyquist-0.2.2}/setup.cfg +0 -0
|
@@ -10,9 +10,9 @@ import sys
|
|
|
10
10
|
import time
|
|
11
11
|
from typing import Any, Optional, Tuple, Union
|
|
12
12
|
|
|
13
|
+
import numpy as np
|
|
13
14
|
import sounddevice as sd
|
|
14
15
|
import tqdm
|
|
15
|
-
import numpy as np
|
|
16
16
|
|
|
17
17
|
from .audio import Audio
|
|
18
18
|
from .paths import CACHE_DIR
|
|
@@ -131,7 +131,13 @@ def play(
|
|
|
131
131
|
when called from a notebook. Useful when you want the audio
|
|
132
132
|
played through the OS audio output rather than as an inline
|
|
133
133
|
player widget.
|
|
134
|
+
|
|
135
|
+
Raises:
|
|
136
|
+
ValueError: If ``audio.sample_rate`` is ``None``.
|
|
134
137
|
"""
|
|
138
|
+
if audio.sample_rate is None:
|
|
139
|
+
raise ValueError("sample_rate is None; cannot play audio.")
|
|
140
|
+
|
|
135
141
|
if normalize:
|
|
136
142
|
audio = audio.normalize(in_place=False)
|
|
137
143
|
audio = audio.clip(in_place=False)
|
|
@@ -173,7 +179,7 @@ def record(
|
|
|
173
179
|
# :mod:`sounddevice` is not available when running in browser, handle separately.
|
|
174
180
|
if _in_browser():
|
|
175
181
|
return _record_in_browser(duration)
|
|
176
|
-
|
|
182
|
+
|
|
177
183
|
device_info = sd.query_devices(sd.default.device[0])
|
|
178
184
|
sample_rate = round(device_info["default_samplerate"])
|
|
179
185
|
num_channels = device_info["max_input_channels"]
|
|
@@ -3,10 +3,11 @@ import io
|
|
|
3
3
|
import json
|
|
4
4
|
import tempfile
|
|
5
5
|
import unittest
|
|
6
|
-
import numpy as np
|
|
7
6
|
from pathlib import Path
|
|
8
7
|
from unittest import mock
|
|
9
8
|
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
10
11
|
from . import device
|
|
11
12
|
|
|
12
13
|
|
|
@@ -446,6 +447,20 @@ class TestPlayDispatch(unittest.TestCase):
|
|
|
446
447
|
fake_audio_widget.assert_called_once()
|
|
447
448
|
fake_display.assert_called_once()
|
|
448
449
|
|
|
450
|
+
def test_missing_sample_rate_raises(self):
|
|
451
|
+
import numpy as np
|
|
452
|
+
|
|
453
|
+
from .audio import Audio
|
|
454
|
+
|
|
455
|
+
audio = Audio(np.zeros(100, dtype=np.float32)) # no sample_rate
|
|
456
|
+
with (
|
|
457
|
+
mock.patch.object(device, "_in_ipython_notebook", return_value=False),
|
|
458
|
+
mock.patch.object(device.sd, "play") as mock_play,
|
|
459
|
+
):
|
|
460
|
+
with self.assertRaises(ValueError):
|
|
461
|
+
device.play(audio)
|
|
462
|
+
mock_play.assert_not_called()
|
|
463
|
+
|
|
449
464
|
def test_force_sounddevice_overrides_notebook(self):
|
|
450
465
|
audio = self._make_audio()
|
|
451
466
|
with (
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyquist-0.2.1 → pyquist-0.2.2}/pyquist/test_data/388954__fullmetaljedi__blues-riff-in-g-nylon.wav
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|