sounddevice_proxy.py 725 B

12345678910111213141516171819202122232425262728
  1. from __future__ import annotations
  2. from typing import TYPE_CHECKING, Any
  3. from typing_extensions import override
  4. from .._utils import LazyProxy
  5. from ._common import MissingDependencyError, format_instructions
  6. if TYPE_CHECKING:
  7. import sounddevice as sounddevice # type: ignore
  8. SOUNDDEVICE_INSTRUCTIONS = format_instructions(library="sounddevice", extra="voice_helpers")
  9. class SounddeviceProxy(LazyProxy[Any]):
  10. @override
  11. def __load__(self) -> Any:
  12. try:
  13. import sounddevice # type: ignore
  14. except ImportError as err:
  15. raise MissingDependencyError(SOUNDDEVICE_INSTRUCTIONS) from err
  16. return sounddevice
  17. if not TYPE_CHECKING:
  18. sounddevice = SounddeviceProxy()