Я пытаюсь записать аудиовыход компьютера (не вход в микрофон, а ввод в динамики - до того, как он покинет устройство) на Mac OS X 10.14.1 с python3 и sounddevice.
Как выКак видно из следующей трассировки, я перепробовал каждое разумное количество входных каналов и количество входных каналов по умолчанию, но не повезло.Я также посмотрел исходный код, но не смог определить мою проблему.
Есть ли способ записи потока вывода звука в моей системе?
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sounddevice as sd
>>> sd.query_devices()
> 0 Built-in Microphone, Core Audio (2 in, 0 out)
< 1 Built-in Output, Core Audio (0 in, 2 out)
>>> sd.default.device = 1
>>> print("Channels should be 0 (number of input channels) or 2 (number of output channels)")
Channels should be 0 (number of input channels) or 2 (number of output channels)
>>> duration = 10
>>> fs = 44100
>>> x = sd.rec(int(duration * fs), samplerate=fs, channels=2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 224, in rec
ctx.input_dtype, callback, blocking, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 2417, in start_stream
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 1301, in __init__
**_remove_self(locals()))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 780, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 2572, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening InputStream: Invalid number of channels [PaErrorCode -9998]
>>> x = sd.rec(int(duration * fs), samplerate=fs, channels=0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 224, in rec
ctx.input_dtype, callback, blocking, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 2417, in start_stream
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 1301, in __init__
**_remove_self(locals()))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 780, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 2572, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening InputStream: Invalid number of channels [PaErrorCode -9998]
>>> x = sd.rec(int(duration * fs), samplerate=fs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 215, in rec
ctx.frames = ctx.check_out(out, frames, channels, dtype, mapping)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sounddevice.py", line 2351, in check_out
'Unable to determine number of input channels')
TypeError: Unable to determine number of input channels