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

Error when attempting to use speaker audio #22

Open
ReddKarma opened this issue Apr 14, 2023 · 1 comment
Open

Error when attempting to use speaker audio #22

ReddKarma opened this issue Apr 14, 2023 · 1 comment

Comments

@ReddKarma
Copy link

ReddKarma commented Apr 14, 2023

I've been trying to get this to recognise speech from the audio output of my headphone speakers, I found the correct device index and set it but it gives me this error whenever i try using a speaker instead of a microphone

line 465, in listen
    assert source.stream is not None, "Audio source must be entered before listening, see documentation for ``AudioSource``; are you using ``source`` outside of a ``with`` statement?"
AssertionError: Audio source must be entered before listening, see documentation for ``AudioSource``; are you using ``source`` outside of a ``with`` statement?

here is a snippet of the code:

with sr.Microphone(sample_rate=16000, device_index=6) as source:
        print("Say something")
        i = 0
        while True:
            audio = r.listen(source)

I didn't change anything big aside from adding comments and setting a device index for my speakers. the error points to the last line
audio = r.listen(source)

@mallorbc
Copy link
Owner

It works with the change you made? Perhaps an argument to pass would be allowing one to set the device index

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

2 participants