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