Skip to content

Commit 18dfc71

Browse files
authored
feat: rename package to pyannoteai.sdk
2 parents 23c7b2e + 14bd7c8 commit 18dfc71

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CHANGELOG
22

3-
## Version 0.1.0a0 (2025-03-05)
3+
## Version 0.1.0a0 (2025-03-14)
44

55
- *Hello world!*

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
</p>
44

55
<div align="center">
6-
<h1>Official Python pyannoteAI SDK </h1>
6+
<h1>Official pyannoteAI Python SDK </h1>
77
</div>
88

99

1010
## Installation
1111

1212
```bash
13-
$ pip install pyannoteAI
13+
$ pip install pyannoteai.sdk
1414
```
1515

1616
Then head over to [`dashboard.pyannote.ai`](https://dashboard.pyannote.ai) and create an API key.
@@ -19,13 +19,15 @@ Then head over to [`dashboard.pyannote.ai`](https://dashboard.pyannote.ai) and c
1919

2020
```python
2121
# instantiate client
22-
from pyannoteai import Client
22+
from pyannoteai.sdk import Client
2323
client = Client("your-api-key")
2424

2525
# upload conversation file
2626
media_url = client.upload('/path/to/conversation.wav')
27+
2728
# submit a diarization job
2829
job_id = client.diarize(media_url)
30+
2931
# retrieve diarization
3032
diarization = client.retrieve(job_id)
3133
# diarization['output']['diarization'] contains diarization output

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "pyannoteAI"
2+
name = "pyannoteai-sdk"
33
description = "Official pyannoteAI Python SDK"
44
readme = "README.md"
55
authors = [
@@ -21,3 +21,6 @@ build-backend = "hatchling.build"
2121

2222
[tool.hatch.version]
2323
source = "vcs"
24+
25+
[tool.hatch.build.targets.wheel]
26+
packages = ["src/pyannoteai"]
File renamed without changes.

src/pyannoteai/client.py renamed to src/pyannoteai/sdk/client.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
import io
2626
import os
2727
import time
28+
import warnings
2829
from pathlib import Path
2930
from typing import Callable, Optional, Union
3031

3132
import requests
3233
from requests import Response
3334
from requests.exceptions import ConnectionError, HTTPError
3435

35-
__version__ = importlib.metadata.version("pyannoteAI")
36+
__version__ = importlib.metadata.version("pyannoteai-sdk")
3637

3738

3839
class PyannoteAIFailedJob(Exception):
@@ -47,7 +48,7 @@ class PyannoteAICanceledJob(Exception):
4748
pass
4849

4950

50-
class UploadingCallbackBytesIO(io.BytesIO):
51+
class _UploadingCallbackBytesIO(io.BytesIO):
5152
"""BytesIO subclass that calls a callback during the upload process
5253
5354
Parameters
@@ -93,8 +94,9 @@ class Client:
9394
9495
Usage
9596
-----
97+
9698
# instantiate client for pyannoteAI web API
97-
>>> from pyannoteAI import Client
99+
>>> from pyannoteai.sdk import Client
98100
>>> client = Client(token="{PYANNOTEAI_API_KEY}")
99101
100102
# upload your audio file to the pyannoteAI web API
@@ -204,8 +206,8 @@ def api_key(self, api_key: str) -> None:
204206
if not api_key:
205207
raise ValueError(
206208
"""
207-
Failed to authenticate to pyannoteAI web API. Please create an API key on https://dashboard.pyannote.ai/ and
208-
provide it either via `PYANNOTEAI_API_TOKEN` environment variable or with `token` parameter."""
209+
Failed to authenticate to pyannoteAI web API. Please create an API key on https://dashboard.pyannote.ai/ and
210+
provide it either via `PYANNOTEAI_API_TOKEN` environment variable or with `token` parameter."""
209211
)
210212

211213
# store the API key and prepare the headers
@@ -285,9 +287,9 @@ def upload(
285287

286288
# for now, only str and Path audio instances are supported
287289
with open(audio, "rb") as f:
288-
# wrap the file object in a UploadingCallbackBytesIO instance
290+
# wrap the file object in a _UploadingCallbackBytesIO instance
289291
# to allow calling the hook during the upload process
290-
data = UploadingCallbackBytesIO(callback, total_size, f.read())
292+
data = _UploadingCallbackBytesIO(callback, total_size, f.read())
291293

292294
if not (isinstance(media_url, str) and media_url.startswith("media://")):
293295
raise ValueError(
@@ -312,6 +314,11 @@ def upload(
312314
# TODO: handle HTTPError returned by the API
313315
response.raise_for_status()
314316

317+
warnings.warn("""
318+
You are using pyannoteAI's temporary storage solution. Your file will be permanently deleted from our servers within 24hs.
319+
If you are running in production, we highly recommend to use your own storage to reduce network latency and obtain results faster.
320+
Please check our documentation at https://docs.pyannote.ai/ for more information.""")
321+
315322
return media_url
316323

317324
def diarize(
@@ -488,15 +495,16 @@ def retrieve(self, job_id: str, every_seconds: int = 10) -> dict:
488495
break
489496

490497
if job_status == "failed":
491-
error = job.get("output", dict()).get(
492-
"error", "Please contact support."
493-
)
498+
error = job.get("output", dict()).get("error", "Please contact support.")
494499
raise PyannoteAIFailedJob(error, job_id)
495500

496501
if job_status == "canceled":
497-
error = job.get("output", dict()).get(
498-
"error", "Please contact support."
499-
)
502+
error = job.get("output", dict()).get("error", "Please contact support.")
500503
raise PyannoteAICanceledJob(error, job_id)
501504

505+
warnings.warn("""
506+
You are using periodic polling to retrieve results.
507+
If you are running in production, we highly recommend to setup a webhook server to obtain results faster, as soon as they are available.
508+
Please check our documentation at https://docs.pyannote.ai/ for more information.""")
509+
502510
return job

0 commit comments

Comments
 (0)