Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unanticipated host error #1

Open
LenBen opened this issue Sep 13, 2023 · 6 comments
Open

Unanticipated host error #1

LenBen opened this issue Sep 13, 2023 · 6 comments

Comments

@LenBen
Copy link

LenBen commented Sep 13, 2023

When I attempt to use the library I get an error. The error message is:
lProject\test.py", line 11, in
stream = p.open(
^^^^^^^
File "C:\Users\lenny\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyaudio_init_.py", line 639, in open
stream = PyAudio.Stream(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\lenny\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyaudio_init_.py", line 441, in init
self._stream = pa.open(**arguments)
^^^^^^^^^^^^^^^^^^^^
OSError: [Errno -9999] Unanticipated host error

The code I am trying to run is:
import pyaudio
import wave

FRAMES_PER_BUFFER = 512
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000

p = pyaudio.PyAudio()

stream = p.open(
format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=FRAMES_PER_BUFFER

)

print("Start recording")

seconds = 5
frames = []

for i in range(0, int(RATE/FRAMES_PER_BUFFER*seconds)):
try:
data = stream.read(FRAMES_PER_BUFFER)
frames.append(data, FRAMES_PER_BUFFER)
except:
print("Life is lemons i like melons and pasta")

stream.stop_stream()
stream.close()

p.terminate()

obj = wave.open("output.wav", "wb")
obj.setnchannels(CHANNELS)
obj.setsampwidth(p.get_sample_size)
obj.setframerate(RATE)
obj.writeframes(b"".join(frames))
obj.close()

I am using windows 11 with python 3.11.5 and pyaudio 0.2.13

Can someone please help?

@CristiFati
Copy link
Owner

Unfortunately, now I'm booted into Ubuntu, so there's nothing I can do at this point. You could post a question on SO.

@CristiFati
Copy link
Owner

I just pulled latest changes from upstream, so you might give another try.

@LenBen
Copy link
Author

LenBen commented Nov 21, 2023

Thank you! I found out that I just needed to move the file to the root folder of my C: drive, for some reason didn't like it on a cloud folder

@LenBen LenBen closed this as completed Nov 21, 2023
@LenBen
Copy link
Author

LenBen commented Nov 23, 2023

Nevermind, it stopped working and is still giving me the same error messge, I've also upgraded pyaudio to the latest version.

@LenBen LenBen reopened this Nov 23, 2023
@benpocklingtonhes
Copy link

am using windows 11 with python 3.11.5 and pyaudio 0.2.13

Can someone please help?

Try using a different machine, I was using a machine that belongs to my organization and the security software installed was protecting data from I/O devices

@arvindmn01
Copy link

I am also getting the same error. I cannot reach out to my vendor, nor can I add an exclusion to execute the code.
Is it possible to use PyAudio to access the microphone on a system with antivirus installed, or what are the alternative methods for utilizing the microphone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants