Open demongolem opened 5 years ago
Upon further probing, even though the above line shows the headset microphone as the default and it is in fact the default for the Windows system I am using, the only device that works is
17 Jack Mic (Realtek HD Audio Front Mic input), Windows WDM-KS (2 in, 0 out)
If I used the plotline.py example for example which is in the repository and I unplug my headset, I see it run without error and pick up my voice.
Usually, I will have my headset plugged in so I can google hangout people online. It doesn't seem right that I have to try to find which device number is Jack Mic and then use that overwriting the default input device for my computer which works just fine on hangout.
The error message and the behavior you are describing are directly provided by the underlying PortAudio library. There is nothing I can do in the sounddevice
module to change that, any changes would have to be done in PortAudio itself.
You should probably ask about this on the PortAudio mailing list: http://portaudio.com/contacts.html
@demongolem Are there any news on this issue?
No, I did report to PortAudio, but there has been no response on that.
OK, thanks for reporting this, could you please provide a link to the issue so we can follow it here?
Thanks for the link!
You would probably reach more people (including PortAudio users, not only core developers) when you ask on the mailing list.
Probably there is somebody else who could try the Plantronics C320 on Windows/MME?
I guess this is the device: https://www.plantronics.com/us/en/product/blackwire-310-320
And just to make sure: This problem only occurs with this one device, right? Did you try other external USB devices?
i have the same problem too .
I have this problem too
Did you ask on the PortAudio mailing list (http://portaudio.com/contacts.html)?
I guess same error. I am also on MacMojave and try to play a sound file if a microphone signal goes above a threshold. I have :
import sounddevice as sd
import soundfile as sf
import numpy as np
duration = 5 # seconds
threshold = 30
filename = "./data/piano.wav"
data, fs = sf.read(filename, dtype='float32')
def print_sound(indata, outdata, frames, time, status):
if status:
print(status)
global threshold, data, fs
volume_norm = 5*np.linalg.norm(indata)
if volume_norm > threshold:
print("so loud!!!!")
sd.play(data, fs)
with sd.Stream(callback=print_sound):
sd.sleep(1000*duration)
When I run this the sound goes above the threshold, however, it cannot open the output Stream as follows;
$python3 main.py
input underflow
input underflow
input underflow
so loud!!!!
so loud!!!!
input overflow, output underflow
so loud!!!!
input overflow, output underflow
so loud!!!!
||PaMacCore (AUHAL)|| Error on line 1316: err=''nope'', msg=Audio Hardware: Illegal Operation
From cffi callback <function _StreamBase.__init__.<locals>.callback_ptr at 0x10caf8680>:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sounddevice.py", line 881, in callback_ptr
callback, idata, odata, frames, time, status)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sounddevice.py", line 2678, in _wrap_callback
callback(*args)
File "main.py", line 17, in print_sound
sd.play(data, fs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sounddevice.py", line 177, in play
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sounddevice.py", line 2578, in start_stream
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sounddevice.py", line 1489, in __init__
**_remove_self(locals()))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sounddevice.py", line 895, in __init__
'Error opening {}'.format(self.__class__.__name__))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sounddevice.py", line 2738, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening OutputStream: Internal PortAudio error [PaErrorCode -9986]
I have restarted my iMac ( Mojave) and still get the same error.
Any help would be much appreciated.
CS
I guess same error too. macOS Big Sur 11.5 beta, sounddevice 0.4.1.
# Used to convert waveform data into a 2-byte numeric sequence
import wave as wave
import numpy as np
import sounddevice as sd
#Sample files
sample_wave_file="./CMU_ARCTIC/cmu_us_aew_arctic/wav/arctic_a0001.wav"
#Load a file
wav=wave.open(sample_wave_file)
#Reads waveform data in PCM format
data=wav.readframes(wav.getnframes())
#Convert data to a 2-byte numeric string
data=np.frombuffer(data, dtype=np.int16)
#Playback data
sd.play(data,wav.getframerate())
status = sd.wait()
When I run this;
(.env) otori334@OTRMBP SSS % python3 /Users/otori334/GitHub/SSS/playback.py
||PaMacCore (AUHAL)|| Error on line 1316: err='-66748', msg=Unknown Error
Traceback (most recent call last):
File "/Users/otori334/GitHub/SSS/playback.py", line 20, in <module>
sd.play(data,wav.getframerate())
File "/Users/otori334/GitHub/SSS/.env/lib/python3.9/site-packages/sounddevice.py", line 174, in play
ctx.start_stream(OutputStream, samplerate, ctx.output_channels,
File "/Users/otori334/GitHub/SSS/.env/lib/python3.9/site-packages/sounddevice.py", line 2573, in start_stream
self.stream = StreamClass(samplerate=samplerate,
File "/Users/otori334/GitHub/SSS/.env/lib/python3.9/site-packages/sounddevice.py", line 1488, in __init__
_StreamBase.__init__(self, kind='output', wrap_callback='array',
File "/Users/otori334/GitHub/SSS/.env/lib/python3.9/site-packages/sounddevice.py", line 892, in __init__
_check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
File "/Users/otori334/GitHub/SSS/.env/lib/python3.9/site-packages/sounddevice.py", line 2738, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening OutputStream: Internal PortAudio error [PaErrorCode -9986]
My problem was solved with this method #299
brew install portaudio --HEAD
Thanks
stream.start()
did the magic for me, before invoking stream.read()
.
sounddevice.PortAudioError: Error opening RawStream: Unanticipated host error [PaErrorCode -9999]: 'Undefined external error.' [MME error 1]
I resolved this by enabling "Let apps access your microphone"
in Windows 10/11.
a setting in Privacy & Security > Microphone
Uninstalling sounddevice from pip
and reinstalling using conda
worked for me
pip uninstall sounddevice
conda install -c conda-forge python-sounddevice
Thank you, @warrenarea I tried it and now the problem is solved.
Uninstalling sounddevice from
pip
and reinstalling usingconda
worked for mepip uninstall sounddevice conda install -c conda-forge python-sounddevice
This worked for me. Thanks.
When trying to record, I use the line
This leads to
When I do
python -m sounddevice
I get this line:Why would this device not be available for recording?