audio.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. from __future__ import annotations
  3. from .speech import (
  4. Speech,
  5. AsyncSpeech,
  6. SpeechWithRawResponse,
  7. AsyncSpeechWithRawResponse,
  8. SpeechWithStreamingResponse,
  9. AsyncSpeechWithStreamingResponse,
  10. )
  11. from ..._compat import cached_property
  12. from ..._resource import SyncAPIResource, AsyncAPIResource
  13. from .translations import (
  14. Translations,
  15. AsyncTranslations,
  16. TranslationsWithRawResponse,
  17. AsyncTranslationsWithRawResponse,
  18. TranslationsWithStreamingResponse,
  19. AsyncTranslationsWithStreamingResponse,
  20. )
  21. from .transcriptions import (
  22. Transcriptions,
  23. AsyncTranscriptions,
  24. TranscriptionsWithRawResponse,
  25. AsyncTranscriptionsWithRawResponse,
  26. TranscriptionsWithStreamingResponse,
  27. AsyncTranscriptionsWithStreamingResponse,
  28. )
  29. __all__ = ["Audio", "AsyncAudio"]
  30. class Audio(SyncAPIResource):
  31. @cached_property
  32. def transcriptions(self) -> Transcriptions:
  33. return Transcriptions(self._client)
  34. @cached_property
  35. def translations(self) -> Translations:
  36. return Translations(self._client)
  37. @cached_property
  38. def speech(self) -> Speech:
  39. return Speech(self._client)
  40. @cached_property
  41. def with_raw_response(self) -> AudioWithRawResponse:
  42. """
  43. This property can be used as a prefix for any HTTP method call to return
  44. the raw response object instead of the parsed content.
  45. For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
  46. """
  47. return AudioWithRawResponse(self)
  48. @cached_property
  49. def with_streaming_response(self) -> AudioWithStreamingResponse:
  50. """
  51. An alternative to `.with_raw_response` that doesn't eagerly read the response body.
  52. For more information, see https://www.github.com/openai/openai-python#with_streaming_response
  53. """
  54. return AudioWithStreamingResponse(self)
  55. class AsyncAudio(AsyncAPIResource):
  56. @cached_property
  57. def transcriptions(self) -> AsyncTranscriptions:
  58. return AsyncTranscriptions(self._client)
  59. @cached_property
  60. def translations(self) -> AsyncTranslations:
  61. return AsyncTranslations(self._client)
  62. @cached_property
  63. def speech(self) -> AsyncSpeech:
  64. return AsyncSpeech(self._client)
  65. @cached_property
  66. def with_raw_response(self) -> AsyncAudioWithRawResponse:
  67. """
  68. This property can be used as a prefix for any HTTP method call to return
  69. the raw response object instead of the parsed content.
  70. For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
  71. """
  72. return AsyncAudioWithRawResponse(self)
  73. @cached_property
  74. def with_streaming_response(self) -> AsyncAudioWithStreamingResponse:
  75. """
  76. An alternative to `.with_raw_response` that doesn't eagerly read the response body.
  77. For more information, see https://www.github.com/openai/openai-python#with_streaming_response
  78. """
  79. return AsyncAudioWithStreamingResponse(self)
  80. class AudioWithRawResponse:
  81. def __init__(self, audio: Audio) -> None:
  82. self._audio = audio
  83. @cached_property
  84. def transcriptions(self) -> TranscriptionsWithRawResponse:
  85. return TranscriptionsWithRawResponse(self._audio.transcriptions)
  86. @cached_property
  87. def translations(self) -> TranslationsWithRawResponse:
  88. return TranslationsWithRawResponse(self._audio.translations)
  89. @cached_property
  90. def speech(self) -> SpeechWithRawResponse:
  91. return SpeechWithRawResponse(self._audio.speech)
  92. class AsyncAudioWithRawResponse:
  93. def __init__(self, audio: AsyncAudio) -> None:
  94. self._audio = audio
  95. @cached_property
  96. def transcriptions(self) -> AsyncTranscriptionsWithRawResponse:
  97. return AsyncTranscriptionsWithRawResponse(self._audio.transcriptions)
  98. @cached_property
  99. def translations(self) -> AsyncTranslationsWithRawResponse:
  100. return AsyncTranslationsWithRawResponse(self._audio.translations)
  101. @cached_property
  102. def speech(self) -> AsyncSpeechWithRawResponse:
  103. return AsyncSpeechWithRawResponse(self._audio.speech)
  104. class AudioWithStreamingResponse:
  105. def __init__(self, audio: Audio) -> None:
  106. self._audio = audio
  107. @cached_property
  108. def transcriptions(self) -> TranscriptionsWithStreamingResponse:
  109. return TranscriptionsWithStreamingResponse(self._audio.transcriptions)
  110. @cached_property
  111. def translations(self) -> TranslationsWithStreamingResponse:
  112. return TranslationsWithStreamingResponse(self._audio.translations)
  113. @cached_property
  114. def speech(self) -> SpeechWithStreamingResponse:
  115. return SpeechWithStreamingResponse(self._audio.speech)
  116. class AsyncAudioWithStreamingResponse:
  117. def __init__(self, audio: AsyncAudio) -> None:
  118. self._audio = audio
  119. @cached_property
  120. def transcriptions(self) -> AsyncTranscriptionsWithStreamingResponse:
  121. return AsyncTranscriptionsWithStreamingResponse(self._audio.transcriptions)
  122. @cached_property
  123. def translations(self) -> AsyncTranslationsWithStreamingResponse:
  124. return AsyncTranslationsWithStreamingResponse(self._audio.translations)
  125. @cached_property
  126. def speech(self) -> AsyncSpeechWithStreamingResponse:
  127. return AsyncSpeechWithStreamingResponse(self._audio.speech)