np_to_mp3 test failure
stephengrice opened this issue · 2 comments
stephengrice commented
=========================================================================================== FAILURES ===========================================================================================
_______________________________________________________________________________________ test_convert_mp3 _______________________________________________________________________________________
def test_convert_mp3():
if os.path.exists("song.mp3"): os.remove("song.mp3")
sample_rate = 44100
signal = sin(65.406, 5, 2, sample_rate)
> np_to_mp3(signal, sample_rate, "song.mp3")
test/test_lib.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
plaintext_daw/lib.py:54: in np_to_mp3
soundfile.write(mp3_path, audio_raw_int16, sample_rate)
../../.local/lib/python3.8/site-packages/soundfile.py:340: in write
with SoundFile(file, 'w', samplerate, channels,
../../.local/lib/python3.8/site-packages/soundfile.py:653: in __init__
self._info = _create_info_struct(file, mode, samplerate, channels,
../../.local/lib/python3.8/site-packages/soundfile.py:1476: in _create_info_struct
info.format = _format_int(format, subtype, endian)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
format = 'mp3', subtype = 'MPEG_LAYER_III', endian = 'FILE'
def _format_int(format, subtype, endian):
"""Return numeric ID for given format|subtype|endian combo."""
result = _check_format(format)
if subtype is None:
subtype = default_subtype(format)
if subtype is None:
raise TypeError(
"No default subtype for major format {0!r}".format(format))
elif not isinstance(subtype, (_unicode, str)):
raise TypeError("Invalid subtype: {0!r}".format(subtype))
try:
result |= _subtypes[subtype.upper()]
except KeyError:
raise ValueError("Unknown subtype: {0!r}".format(subtype))
if endian is None:
endian = 'FILE'
elif not isinstance(endian, (_unicode, str)):
raise TypeError("Invalid endian-ness: {0!r}".format(endian))
try:
result |= _endians[endian.upper()]
except KeyError:
raise ValueError("Unknown endian-ness: {0!r}".format(endian))
info = _ffi.new("SF_INFO*")
info.format = result
info.channels = 1
if _snd.sf_format_check(info) == _snd.SF_FALSE:
> raise ValueError(
"Invalid combination of format, subtype and endian")
E ValueError: Invalid combination of format, subtype and endian
../../.local/lib/python3.8/site-packages/soundfile.py:1434: ValueError
=================================================================================== short test summary info ====================================================================================
FAILED test/test_lib.py::test_convert_mp3 - ValueError: Invalid combination of format, subtype and endian
================================================================================ 1 failed, 24 passed in 23.46s
Not sure what the fix is here. I may have something set up incorrectly. @LTstrange can you help me with this? Have you seen this before?
I should have ran the tests before merging your PR, but I forgot to. So I have to open an issue instead 😁
LTstrange commented
I resolved the previous error, but more errors have emerged.