Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc committed Jan 8, 2025
2 parents 3260e8a + a3042be commit baa9e99
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cozepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .audio.rooms import CreateRoomResp
from .audio.speech import AudioFormat
from .audio.transcriptions import CreateTranslationResp
from .audio.transcriptions import CreateTranscriptionsResp
from .audio.voices import Voice
from .auth import (
AsyncDeviceOAuthApp,
Expand Down Expand Up @@ -143,7 +143,7 @@
"Voice",
"AudioFormat",
# audio.transcriptions
"CreateTranslationResp",
"CreateTranscriptionsResp",
# auth
"AsyncDeviceOAuthApp",
"AsyncJWTOAuthApp",
Expand Down
18 changes: 9 additions & 9 deletions cozepy/audio/transcriptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from cozepy.util import remove_url_trailing_slash


class CreateTranslationResp(CozeModel):
class CreateTranscriptionsResp(CozeModel):
# The text of translation
text: str

Expand All @@ -23,18 +23,18 @@ def create(
*,
file: FileTypes,
**kwargs,
) -> CreateTranslationResp:
) -> CreateTranscriptionsResp:
"""
create translation
create transcriptions
:param file: The file to be translated.
:return: create translation result
:return: create transcriptions result
"""
url = f"{self._base_url}/v1/audio/transcriptions"
headers: Optional[dict] = kwargs.get("headers")
files = {"file": _try_fix_file(file)}
return self._requester.request(
"post", url, stream=False, cast=CreateTranslationResp, headers=headers, files=files
"post", url, stream=False, cast=CreateTranscriptionsResp, headers=headers, files=files
)


Expand All @@ -53,16 +53,16 @@ async def create(
*,
file: FileTypes,
**kwargs,
) -> CreateTranslationResp:
) -> CreateTranscriptionsResp:
"""
create translation
create transcriptions
:param file: The file to be translated.
:return: create translation result
:return: create transcriptions result
"""
url = f"{self._base_url}/v1/audio/transcriptions"
files = {"file": _try_fix_file(file)}
headers: Optional[dict] = kwargs.get("headers")
return await self._requester.arequest(
"post", url, stream=False, cast=CreateTranslationResp, headers=headers, files=files
"post", url, stream=False, cast=CreateTranscriptionsResp, headers=headers, files=files
)
14 changes: 7 additions & 7 deletions tests/test_audio_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tests.test_util import logid_key


def mock_create_translation(respx_mock):
def mock_create_transcriptions(respx_mock):
logid = random_hex(10)
raw_response = httpx.Response(
200,
Expand All @@ -25,11 +25,11 @@ def mock_create_translation(respx_mock):


@pytest.mark.respx(base_url="https://api.coze.com")
class TestAudioTranslation:
def test_sync_translation_create(self, respx_mock):
class TestSyncAudioTranscriptions:
def test_sync_transcriptions_create(self, respx_mock):
coze = Coze(auth=TokenAuth(token="token"))

mock_logid = mock_create_translation(respx_mock)
mock_logid = mock_create_transcriptions(respx_mock)

res = coze.audio.transcriptions.create(file=("filename", "content"))
assert res
Expand All @@ -39,11 +39,11 @@ def test_sync_translation_create(self, respx_mock):

@pytest.mark.respx(base_url="https://api.coze.com")
@pytest.mark.asyncio
class TestAsyncAudioTranslation:
async def test_async_translation_create(self, respx_mock):
class TestAsyncAudioTranscriptions:
async def test_async_transcriptions_create(self, respx_mock):
coze = AsyncCoze(auth=TokenAuth(token="token"))

mock_logid = mock_create_translation(respx_mock)
mock_logid = mock_create_transcriptions(respx_mock)

res = await coze.audio.transcriptions.create(file=("filename", "content"))
assert res
Expand Down

0 comments on commit baa9e99

Please sign in to comment.