Skip to content

Commit

Permalink
Merge pull request #419 from Tenzer/make-pyaudio-code-conditional
Browse files Browse the repository at this point in the history
Stop importing pyaudio as soon as the Microphone class is parsed
  • Loading branch information
dvonthenen authored Jun 13, 2024
2 parents 344cb46 + a4fd2e8 commit 102b807
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions deepgram/audio/microphone/microphone.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import inspect
import asyncio
import threading
from typing import Optional, Callable
from typing import Optional, Callable, TYPE_CHECKING
import logging

from ...utils import verboselogs
from .constants import LOGGING, CHANNELS, RATE, CHUNK

if TYPE_CHECKING:
import pyaudio


class Microphone: # pylint: disable=too-many-instance-attributes
"""
Expand All @@ -20,10 +23,8 @@ class Microphone: # pylint: disable=too-many-instance-attributes
_logger: verboselogs.VerboseLogger
_exit: threading.Event

import pyaudio # pylint: disable=import-outside-toplevel

_audio: pyaudio.PyAudio
_stream: pyaudio.Stream
_audio: "pyaudio.PyAudio"
_stream: "pyaudio.Stream"
_chunk: int
_rate: int
_format: int
Expand Down

0 comments on commit 102b807

Please sign in to comment.