|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import TYPE_CHECKING |
6 | | - |
7 | 5 | from .speech import Speech, AsyncSpeech, SpeechWithRawResponse, AsyncSpeechWithRawResponse |
| 6 | +from ..._compat import cached_property |
8 | 7 | from ..._resource import SyncAPIResource, AsyncAPIResource |
9 | 8 | from .translations import Translations, AsyncTranslations, TranslationsWithRawResponse, AsyncTranslationsWithRawResponse |
10 | 9 | from .transcriptions import ( |
|
14 | 13 | AsyncTranscriptionsWithRawResponse, |
15 | 14 | ) |
16 | 15 |
|
17 | | -if TYPE_CHECKING: |
18 | | - from ..._client import OpenAI, AsyncOpenAI |
19 | | - |
20 | 16 | __all__ = ["Audio", "AsyncAudio"] |
21 | 17 |
|
22 | 18 |
|
23 | 19 | class Audio(SyncAPIResource): |
24 | | - transcriptions: Transcriptions |
25 | | - translations: Translations |
26 | | - speech: Speech |
27 | | - with_raw_response: AudioWithRawResponse |
| 20 | + @cached_property |
| 21 | + def transcriptions(self) -> Transcriptions: |
| 22 | + return Transcriptions(self._client) |
| 23 | + |
| 24 | + @cached_property |
| 25 | + def translations(self) -> Translations: |
| 26 | + return Translations(self._client) |
| 27 | + |
| 28 | + @cached_property |
| 29 | + def speech(self) -> Speech: |
| 30 | + return Speech(self._client) |
28 | 31 |
|
29 | | - def __init__(self, client: OpenAI) -> None: |
30 | | - super().__init__(client) |
31 | | - self.transcriptions = Transcriptions(client) |
32 | | - self.translations = Translations(client) |
33 | | - self.speech = Speech(client) |
34 | | - self.with_raw_response = AudioWithRawResponse(self) |
| 32 | + @cached_property |
| 33 | + def with_raw_response(self) -> AudioWithRawResponse: |
| 34 | + return AudioWithRawResponse(self) |
35 | 35 |
|
36 | 36 |
|
37 | 37 | class AsyncAudio(AsyncAPIResource): |
38 | | - transcriptions: AsyncTranscriptions |
39 | | - translations: AsyncTranslations |
40 | | - speech: AsyncSpeech |
41 | | - with_raw_response: AsyncAudioWithRawResponse |
42 | | - |
43 | | - def __init__(self, client: AsyncOpenAI) -> None: |
44 | | - super().__init__(client) |
45 | | - self.transcriptions = AsyncTranscriptions(client) |
46 | | - self.translations = AsyncTranslations(client) |
47 | | - self.speech = AsyncSpeech(client) |
48 | | - self.with_raw_response = AsyncAudioWithRawResponse(self) |
| 38 | + @cached_property |
| 39 | + def transcriptions(self) -> AsyncTranscriptions: |
| 40 | + return AsyncTranscriptions(self._client) |
| 41 | + |
| 42 | + @cached_property |
| 43 | + def translations(self) -> AsyncTranslations: |
| 44 | + return AsyncTranslations(self._client) |
| 45 | + |
| 46 | + @cached_property |
| 47 | + def speech(self) -> AsyncSpeech: |
| 48 | + return AsyncSpeech(self._client) |
| 49 | + |
| 50 | + @cached_property |
| 51 | + def with_raw_response(self) -> AsyncAudioWithRawResponse: |
| 52 | + return AsyncAudioWithRawResponse(self) |
49 | 53 |
|
50 | 54 |
|
51 | 55 | class AudioWithRawResponse: |
|
0 commit comments