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

Stop importing pyaudio as soon as the Microphone class is parsed #419

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading