========================================================================================================================= FAILURES ==========================================================================================================================
________________________________________________________________________________________________________ test_FFmpegAudioSource_change_sample_width _________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
self = <[AttributeError("'FFmpegAudioSource' object has no attribute '_sampling_rate'") raised in repr()] FFmpegAudioSource object at 0x1921acccc50>, filename = 'tests/data/DTMF_tones_16KHZ_mono.flac', sampling_rate = None, sample_width = 4
channels = None
def __init__(
self,
filename: str,
sampling_rate: int | None = None,
sample_width: int | None = None,
channels: int | None = None,
) -> None:
self._filename = str(filename)
self._process = None
ffmpeg_path = _find_ffmpeg()
if ffmpeg_path is None:
raise AudioIOError("ffmpeg not found on PATH")
cmd = [
ffmpeg_path,
"-loglevel",
"fatal",
"-nostdin",
"-i",
self._filename,
]
if sampling_rate is not None:
cmd += ["-ar", str(sampling_rate)]
if channels is not None:
cmd += ["-ac", str(channels)]
if sample_width is not None:
codec = self._SW_TO_CODEC.get(sample_width)
if codec is None:
raise AudioParameterError(
"sample_width must be one of 1, 2, or 4, "
"got {}".format(sample_width)
)
cmd += ["-acodec", codec]
cmd += ["-f", "wav", "pipe:1"]
try:
self._process = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
except OSError as exc:
raise AudioIOError(f"Failed to start ffmpeg: {exc}") from exc
try:
> wfp = wave.open(self._process.stdout, "rb") # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
auditok/io.py:651:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.11/wave.py:631: in open
return Wave_read(f)
^^^^^^^^^^^^
/usr/local/lib/python3.11/wave.py:283: in __init__
self.initfp(f)
/usr/local/lib/python3.11/wave.py:263: in initfp
self._read_fmt_chunk(chunk)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <wave.Wave_read object at 0x1921accde90>, chunk = <wave._Chunk object at 0x1921acccd10>
def _read_fmt_chunk(self, chunk):
try:
wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<HHLLH', chunk.read(14))
except struct.error:
raise EOFError from None
if wFormatTag == WAVE_FORMAT_PCM:
try:
sampwidth = struct.unpack_from('<H', chunk.read(2))[0]
except struct.error:
raise EOFError from None
self._sampwidth = (sampwidth + 7) // 8
if not self._sampwidth:
raise Error('bad sample width')
else:
> raise Error('unknown format: %r' % (wFormatTag,))
E wave.Error: unknown format: 65534
/usr/local/lib/python3.11/wave.py:388: Error
The above exception was the direct cause of the following exception:
@requires_ffmpeg
def test_FFmpegAudioSource_change_sample_width():
test_file = "tests/data/DTMF_tones_16KHZ_mono.flac"
> audio_source = FFmpegAudioSource(test_file, sample_width=4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_AudioSource.py:273:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'FFmpegAudioSource' object has no attribute '_sampling_rate'") raised in repr()] FFmpegAudioSource object at 0x1921acccc50>, filename = 'tests/data/DTMF_tones_16KHZ_mono.flac', sampling_rate = None, sample_width = 4
channels = None
def __init__(
self,
filename: str,
sampling_rate: int | None = None,
sample_width: int | None = None,
channels: int | None = None,
) -> None:
self._filename = str(filename)
self._process = None
ffmpeg_path = _find_ffmpeg()
if ffmpeg_path is None:
raise AudioIOError("ffmpeg not found on PATH")
cmd = [
ffmpeg_path,
"-loglevel",
"fatal",
"-nostdin",
"-i",
self._filename,
]
if sampling_rate is not None:
cmd += ["-ar", str(sampling_rate)]
if channels is not None:
cmd += ["-ac", str(channels)]
if sample_width is not None:
codec = self._SW_TO_CODEC.get(sample_width)
if codec is None:
raise AudioParameterError(
"sample_width must be one of 1, 2, or 4, "
"got {}".format(sample_width)
)
cmd += ["-acodec", codec]
cmd += ["-f", "wav", "pipe:1"]
try:
self._process = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
except OSError as exc:
raise AudioIOError(f"Failed to start ffmpeg: {exc}") from exc
try:
wfp = wave.open(self._process.stdout, "rb") # type: ignore[arg-type]
sr = wfp.getframerate()
sw = wfp.getsampwidth()
ch = wfp.getnchannels()
except Exception as exc:
stderr = b""
if self._process is not None and self._process.stderr is not None:
stderr = self._process.stderr.read()
self._close_process()
err_msg = f"Failed to read audio from {filename!r}"
if stderr:
err_msg += f": {stderr.decode(errors='replace').strip()}"
> raise AudioIOError(err_msg) from exc
E auditok.exceptions.AudioIOError: Failed to read audio from 'tests/data/DTMF_tones_16KHZ_mono.flac'
auditok/io.py:663: AudioIOError
__________________________________________________________________________________________________________________ test_region_plot[mono] ___________________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
channels = 1
@pytest.mark.parametrize("channels", [1, 2], ids=["mono", "stereo"])
def test_region_plot(channels):
type_ = "mono" if channels == 1 else "stereo"
audio_filename = "tests/data/test_split_10HZ_{}.raw".format(type_)
image_filename = "tests/images/plot_{}_region.png".format(type_)
expected_image = plt.imread(image_filename)
with TemporaryDirectory() as tmpdir:
output_image_filename = os.path.join(tmpdir, "image.png")
region = AudioRegion.load(audio_filename, sr=10, sw=2, ch=channels)
region.plot(show=False, save_as=output_image_filename)
output_image = plt.imread(output_image_filename)
if SAVE_NEW_IMAGES:
shutil.copy(output_image_filename, image_filename)
> assert (output_image == expected_image).all() # mono, stereo
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E AssertionError: assert np.False_
E + where np.False_ = <built-in method all of numpy.ndarray object at 0x1921b890e70>()
E + where <built-in method all of numpy.ndarray object at 0x1921b890e70> = array([[[0.28...dtype=float32) == array([[[0.28...dtype=float32)
E
E Full diff:
E array([[[0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E ...,
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],...
E
E ...Full output truncated (45 lines hidden), use '-vv' to show.all
tests/test_plotting.py:33: AssertionError
_________________________________________________________________________________________________________________ test_region_plot[stereo] __________________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
channels = 2
@pytest.mark.parametrize("channels", [1, 2], ids=["mono", "stereo"])
def test_region_plot(channels):
type_ = "mono" if channels == 1 else "stereo"
audio_filename = "tests/data/test_split_10HZ_{}.raw".format(type_)
image_filename = "tests/images/plot_{}_region.png".format(type_)
expected_image = plt.imread(image_filename)
with TemporaryDirectory() as tmpdir:
output_image_filename = os.path.join(tmpdir, "image.png")
region = AudioRegion.load(audio_filename, sr=10, sw=2, ch=channels)
region.plot(show=False, save_as=output_image_filename)
output_image = plt.imread(output_image_filename)
if SAVE_NEW_IMAGES:
shutil.copy(output_image_filename, image_filename)
> assert (output_image == expected_image).all() # mono, stereo
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E AssertionError: assert np.False_
E + where np.False_ = <built-in method all of numpy.ndarray object at 0x1921b9ae310>()
E + where <built-in method all of numpy.ndarray object at 0x1921b9ae310> = array([[[0.28...dtype=float32) == array([[[0.28...dtype=float32)
E
E Full diff:
E array([[[0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E ...,
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],...
E
E ...Full output truncated (45 lines hidden), use '-vv' to show.all
tests/test_plotting.py:33: AssertionError
_____________________________________________________________________________________________________________ test_region_split_and_plot[mono] ______________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
channels = 1, use_channel = None
@pytest.mark.parametrize(
"channels, use_channel",
[
(1, None), # mono
(2, "any"), # stereo_any
(2, 0), # stereo_uc_0
(2, 1), # stereo_uc_1
(2, "mix"), # stereo_uc_mix
],
ids=["mono", "stereo_any", "stereo_uc_0", "stereo_uc_1", "stereo_uc_mix"],
)
def test_region_split_and_plot(channels, use_channel):
type_ = "mono" if channels == 1 else "stereo"
audio_filename = "tests/data/test_split_10HZ_{}.raw".format(type_)
if type_ == "mono":
image_filename = "tests/images/split_and_plot_mono_region.png"
else:
image_filename = (
f"tests/images/split_and_plot_uc_{use_channel}_stereo_region.png"
)
expected_image = plt.imread(image_filename)
with TemporaryDirectory() as tmpdir:
output_image_filename = os.path.join(tmpdir, "image.png")
region = AudioRegion.load(audio_filename, sr=10, sw=2, ch=channels)
region.split_and_plot(
aw=0.1,
uc=use_channel,
max_silence=0,
show=False,
save_as=output_image_filename,
)
output_image = plt.imread(output_image_filename)
if SAVE_NEW_IMAGES:
shutil.copy(output_image_filename, image_filename)
> assert (output_image == expected_image).all()
E AssertionError: assert np.False_
E + where np.False_ = <built-in method all of numpy.ndarray object at 0x19110afa1f0>()
E + where <built-in method all of numpy.ndarray object at 0x19110afa1f0> = array([[[0.28...dtype=float32) == array([[[0.28...dtype=float32)
E
E Full diff:
E array([[[0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E ...,
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],...
E
E ...Full output truncated (45 lines hidden), use '-vv' to show.all
tests/test_plotting.py:72: AssertionError
__________________________________________________________________________________________________________ test_region_split_and_plot[stereo_any] ___________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
channels = 2, use_channel = 'any'
@pytest.mark.parametrize(
"channels, use_channel",
[
(1, None), # mono
(2, "any"), # stereo_any
(2, 0), # stereo_uc_0
(2, 1), # stereo_uc_1
(2, "mix"), # stereo_uc_mix
],
ids=["mono", "stereo_any", "stereo_uc_0", "stereo_uc_1", "stereo_uc_mix"],
)
def test_region_split_and_plot(channels, use_channel):
type_ = "mono" if channels == 1 else "stereo"
audio_filename = "tests/data/test_split_10HZ_{}.raw".format(type_)
if type_ == "mono":
image_filename = "tests/images/split_and_plot_mono_region.png"
else:
image_filename = (
f"tests/images/split_and_plot_uc_{use_channel}_stereo_region.png"
)
expected_image = plt.imread(image_filename)
with TemporaryDirectory() as tmpdir:
output_image_filename = os.path.join(tmpdir, "image.png")
region = AudioRegion.load(audio_filename, sr=10, sw=2, ch=channels)
region.split_and_plot(
aw=0.1,
uc=use_channel,
max_silence=0,
show=False,
save_as=output_image_filename,
)
output_image = plt.imread(output_image_filename)
if SAVE_NEW_IMAGES:
shutil.copy(output_image_filename, image_filename)
> assert (output_image == expected_image).all()
E AssertionError: assert np.False_
E + where np.False_ = <built-in method all of numpy.ndarray object at 0x1921ba00f90>()
E + where <built-in method all of numpy.ndarray object at 0x1921ba00f90> = array([[[0.28...dtype=float32) == array([[[0.28...dtype=float32)
E
E Full diff:
E array([[[0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E ...,
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],...
E
E ...Full output truncated (45 lines hidden), use '-vv' to show.all
tests/test_plotting.py:72: AssertionError
__________________________________________________________________________________________________________ test_region_split_and_plot[stereo_uc_0] __________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
channels = 2, use_channel = 0
@pytest.mark.parametrize(
"channels, use_channel",
[
(1, None), # mono
(2, "any"), # stereo_any
(2, 0), # stereo_uc_0
(2, 1), # stereo_uc_1
(2, "mix"), # stereo_uc_mix
],
ids=["mono", "stereo_any", "stereo_uc_0", "stereo_uc_1", "stereo_uc_mix"],
)
def test_region_split_and_plot(channels, use_channel):
type_ = "mono" if channels == 1 else "stereo"
audio_filename = "tests/data/test_split_10HZ_{}.raw".format(type_)
if type_ == "mono":
image_filename = "tests/images/split_and_plot_mono_region.png"
else:
image_filename = (
f"tests/images/split_and_plot_uc_{use_channel}_stereo_region.png"
)
expected_image = plt.imread(image_filename)
with TemporaryDirectory() as tmpdir:
output_image_filename = os.path.join(tmpdir, "image.png")
region = AudioRegion.load(audio_filename, sr=10, sw=2, ch=channels)
region.split_and_plot(
aw=0.1,
uc=use_channel,
max_silence=0,
show=False,
save_as=output_image_filename,
)
output_image = plt.imread(output_image_filename)
if SAVE_NEW_IMAGES:
shutil.copy(output_image_filename, image_filename)
> assert (output_image == expected_image).all()
E AssertionError: assert np.False_
E + where np.False_ = <built-in method all of numpy.ndarray object at 0x1921baf7510>()
E + where <built-in method all of numpy.ndarray object at 0x1921baf7510> = array([[[0.28...dtype=float32) == array([[[0.28...dtype=float32)
E
E Full diff:
E array([[[0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E ...,
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],...
E
E ...Full output truncated (45 lines hidden), use '-vv' to show.all
tests/test_plotting.py:72: AssertionError
__________________________________________________________________________________________________________ test_region_split_and_plot[stereo_uc_1] __________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
channels = 2, use_channel = 1
@pytest.mark.parametrize(
"channels, use_channel",
[
(1, None), # mono
(2, "any"), # stereo_any
(2, 0), # stereo_uc_0
(2, 1), # stereo_uc_1
(2, "mix"), # stereo_uc_mix
],
ids=["mono", "stereo_any", "stereo_uc_0", "stereo_uc_1", "stereo_uc_mix"],
)
def test_region_split_and_plot(channels, use_channel):
type_ = "mono" if channels == 1 else "stereo"
audio_filename = "tests/data/test_split_10HZ_{}.raw".format(type_)
if type_ == "mono":
image_filename = "tests/images/split_and_plot_mono_region.png"
else:
image_filename = (
f"tests/images/split_and_plot_uc_{use_channel}_stereo_region.png"
)
expected_image = plt.imread(image_filename)
with TemporaryDirectory() as tmpdir:
output_image_filename = os.path.join(tmpdir, "image.png")
region = AudioRegion.load(audio_filename, sr=10, sw=2, ch=channels)
region.split_and_plot(
aw=0.1,
uc=use_channel,
max_silence=0,
show=False,
save_as=output_image_filename,
)
output_image = plt.imread(output_image_filename)
if SAVE_NEW_IMAGES:
shutil.copy(output_image_filename, image_filename)
> assert (output_image == expected_image).all()
E AssertionError: assert np.False_
E + where np.False_ = <built-in method all of numpy.ndarray object at 0x1921e59b9f0>()
E + where <built-in method all of numpy.ndarray object at 0x1921e59b9f0> = array([[[0.28...dtype=float32) == array([[[0.28...dtype=float32)
E
E Full diff:
E array([[[0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E ...,
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],...
E
E ...Full output truncated (45 lines hidden), use '-vv' to show.all
tests/test_plotting.py:72: AssertionError
_________________________________________________________________________________________________________ test_region_split_and_plot[stereo_uc_mix] _________________________________________________________________________________________________________
[gw0] freebsd15 -- Python 3.11.15 /usr/local/bin/python3.11
channels = 2, use_channel = 'mix'
@pytest.mark.parametrize(
"channels, use_channel",
[
(1, None), # mono
(2, "any"), # stereo_any
(2, 0), # stereo_uc_0
(2, 1), # stereo_uc_1
(2, "mix"), # stereo_uc_mix
],
ids=["mono", "stereo_any", "stereo_uc_0", "stereo_uc_1", "stereo_uc_mix"],
)
def test_region_split_and_plot(channels, use_channel):
type_ = "mono" if channels == 1 else "stereo"
audio_filename = "tests/data/test_split_10HZ_{}.raw".format(type_)
if type_ == "mono":
image_filename = "tests/images/split_and_plot_mono_region.png"
else:
image_filename = (
f"tests/images/split_and_plot_uc_{use_channel}_stereo_region.png"
)
expected_image = plt.imread(image_filename)
with TemporaryDirectory() as tmpdir:
output_image_filename = os.path.join(tmpdir, "image.png")
region = AudioRegion.load(audio_filename, sr=10, sw=2, ch=channels)
region.split_and_plot(
aw=0.1,
uc=use_channel,
max_silence=0,
show=False,
save_as=output_image_filename,
)
output_image = plt.imread(output_image_filename)
if SAVE_NEW_IMAGES:
shutil.copy(output_image_filename, image_filename)
> assert (output_image == expected_image).all()
E AssertionError: assert np.False_
E + where np.False_ = <built-in method all of numpy.ndarray object at 0x1922a4b2670>()
E + where <built-in method all of numpy.ndarray object at 0x1922a4b2670> = array([[[0.28...dtype=float32) == array([[[0.28...dtype=float32)
E
E Full diff:
E array([[[0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],
E ...,
E [0.28235295, 0.16470589, 0.21176471, 0.2 ],...
E
E ...Full output truncated (45 lines hidden), use '-vv' to show.all
tests/test_plotting.py:72: AssertionError
===================================================================================================================== warnings summary ======================================================================================================================
tests/test_cmdline.py::TestSubcommandDispatch::test_implicit_split_with_file
tests/test_cmdline.py::TestSubcommandDispatch::test_explicit_split_with_file
tests/test_cmdline.py::TestAudioParamsNotForcedOnFileInput::test_split_mp3_no_audio_params
tests/test_cmdline.py::TestAudioParamsNotForcedOnFileInput::test_split_mp3_explicit_rate_ignored
tests/test_cmdline.py::TestDeprecationWarnings::test_join_detections_warns
tests/test_cmdline.py::TestDuplicateOptions::test_no_error_when_no_duplicates
/usr/ports/audio/py-auditok/work-py311/auditok-0.4.2/auditok/workers.py:89: DeprecationWarning: 'drop_trailing_silence' is deprecated and will be removed in a future version. Use max_trailing_silence=0 to drop trailing silence, or max_trailing_silence=None (default) to keep all trailing silence (determined by max_silence).
self._audio_region_gen = split(**kwargs)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
-------- coverage: platform freebsd15, python 3.11.15-final-0 --------
Name Stmts Miss Cover
---------------------------------------------------
auditok/__init__.py 6 0 100%
auditok/audio.py 426 24 94%
auditok/cmdline.py 338 79 77%
auditok/core.py 228 20 91%
auditok/exceptions.py 13 0 100%
auditok/io.py 503 125 75%
auditok/plotting.py 87 5 94%
auditok/signal.py 22 2 91%
auditok/util.py 296 50 83%
auditok/widget.py 70 2 97%
auditok/workers.py 338 38 89%
tests/test_AudioReader.py 393 5 99%
tests/test_AudioSource.py 543 11 98%
tests/test_StreamTokenizer.py 494 0 100%
tests/test_audio.py 563 0 100%
tests/test_cmdline.py 274 0 100%
tests/test_fix_pauses.py 161 0 100%
tests/test_io.py 381 0 100%
tests/test_plotting.py 41 3 93%
tests/test_signal.py 19 0 100%
tests/test_trim.py 181 0 100%
tests/test_util.py 45 0 100%
tests/test_widget.py 144 0 100%
tests/test_workers.py 185 16 91%
---------------------------------------------------
TOTAL 5751 380 93%
======================================================================================================== 8 failed, 768 passed, 6 warnings in 10.88s =========================================================================================================
Version: 0.4.2
Python 3.11
FreeBSD 15 STABLE