I'm using the 64-bit PyAudio build available here, on Windows 7. When I import pyaudio and do pyaudio.PyAudio()
, it works fine, but a large amount of what seems to be debug info is printed to stderr. There was a previous question on Stackoverflow about this here, but it's had no activity for over a year and appears unresolved.
As the asker of that question noted in his reply to the answer, redirecting stderr (by doing sys.stderr = somethingelse
) does not stop the error messages from going to stderr. Even if it did, I don't want to redirect all of stderr just to handle PyAudio.
I have a suspicion that the problem is that this build of PyAudio and/or the PortAudio that comes with it was compiled with some sort of debug flag that is causing the debug info to be printed "raw" somewhere in the C extension code, bypassing the Python IO streams. So what I'm asking is:
- Can anyone confirm this behavior, and/or confirm that it doesn't happen with a different build of PyAudio for Win64? (I don't have the setup to compile PyAudio.)
- Is there any way to fix it without recompiling PyAudio? By "fix it" I mean suppress this debug output only from PyAudio (without redirecting stderr completely).
(If it's just an issue with this build I might try to contact the fellow who has made these 64-bit builds available and ask if he intentionally put up a debug version, since it's possible he just forgot to turn off debug when compiling.)
Edit: Here are the messages I'm getting. I'll try to condense them a bit because they're hundreds of lines long. I should also note that these don't look like error messages; they just seem to be status messages about various devices. I first get:
before paHostApiInitializers[0].
after paHostApiInitializers[0].
before paHostApiInitializers[1].
WASAPI: device idx: 00
WASAPI: ---------------
WASAPI:0| name[Realtek Digital Output (Realtek High Definition Audio)]
WASAPI:0| form-factor[8]
WASAPI:0| def.SR[48000] max.CH[2] latency{hi[0.010000] lo[0.003000]}
WASAPI: device idx: 01
Then a series of other similar messages starting with WASAPI and mentioning other devices (line in, microphone, etc.). Then:
WASAPI: initialized ok
after paHostApiInitializers[1].
before paHostApiInitializers[2].
Setup called
Enum called
noError = 0
Enum called
noError = 1
Device 1 has render alias
Device 1 has capture alias
. . . and again a bunch of other similar messages about "Enum called" and "capture alias" and so on. Then:
Interfaces found: 7
Device 1 has render alias
Device 1 has capture alias
Interface 1, Name: ATI HD Audio rear output
Creating pin 0:
No standard streaming
Creating pin 1:
Not source/sink
Filter NOT created
. . . and a series of similar blocks of messages for other device numbers. Then at the end:
after paHostApiInitializers[2].
That's what I see just on doing pyaudio.PyAudio()
.