Skip to content

Commit

Permalink
docs: PyAudioWrapper.get_pyaudio()
Browse files Browse the repository at this point in the history
  • Loading branch information
ftnext committed Nov 5, 2024
1 parent 87db628 commit affab62
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion speech_recognition/microphone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
class PyAudioWrapper:
@staticmethod
def get_pyaudio() -> pyaudio.PyAudio:
"""Returns pyaudio.PyAudio instance.
Checks pyaudio's installation, throws exceptions if pyaudio can't be found
"""
try:
import pyaudio
except ImportError:
raise AttributeError("Could not find PyAudio; check installation")
raise AttributeError(
"Could not find PyAudio; Run `pip install SpeechRecognition[audio]`"
)
return pyaudio.PyAudio()

@staticmethod
Expand Down

0 comments on commit affab62

Please sign in to comment.