disband 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
disband-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Disband
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
disband-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: disband
3
+ Version: 0.1.1
4
+ Summary: Python client for the Disband stem separation API
5
+ Keywords: stem separation,vocal remover,audio,music,api
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Framework :: AnyIO
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Multimedia :: Sound/Audio
12
+ Classifier: Typing :: Typed
13
+ Requires-Dist: anyio>=4.10,<5
14
+ Requires-Dist: httpx2>=2.16,<3
15
+ Requires-Dist: pydantic>=2.7,<3
16
+ Requires-Python: >=3.11
17
+ Project-URL: Homepage, https://disband.io/docs
18
+ Project-URL: Repository, https://github.com/disbandio/disband-python
19
+ Description-Content-Type: text/markdown
20
+
21
+ <p align="center">
22
+ <img src="https://disband.io/favicon.svg" alt="" width="128">
23
+ </p>
24
+
25
+ <h1 align="center">Disband</h1>
26
+
27
+ <p align="center">
28
+ Python SDK for the stem separation API at <a href="https://disband.io">disband.io</a>
29
+ <br><br>
30
+ <a href="https://pypi.org/project/disband/"><img src="https://img.shields.io/pypi/v/disband?color=blue" alt="Version"></a>
31
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/disbandio/disband-python?color=blue" alt="License"></a>
32
+ </p>
33
+
34
+ ## Usage
35
+
36
+ ```sh
37
+ pip install disband
38
+ ```
39
+
40
+ Create a key on [API keys](https://disband.io/app/keys) and set it as `DISBAND_KEY`.
41
+
42
+ ## Examples
43
+
44
+ ### Split a song
45
+
46
+ ```python
47
+ from disband import Disband
48
+
49
+ # reads DISBAND_KEY
50
+ with Disband() as client:
51
+ separation = client.separations.create("song.mp3", stems=["vocals", "instrumental"], formats=["mp3"])
52
+ ready = client.separations.wait(separation.id)
53
+
54
+ for stem, files in ready.stems.items():
55
+ # silent stems have no files
56
+ if files.mp3 is not None:
57
+ client.download(files.mp3, f"{stem}.mp3")
58
+ ```
59
+
60
+ ### Async
61
+
62
+ ```python
63
+ import asyncio
64
+
65
+ from disband import AsyncDisband
66
+
67
+
68
+ async def main() -> None:
69
+ async with AsyncDisband() as client:
70
+ # one stem or several
71
+ separation = await client.separations.create("song.mp3", stems="vocals")
72
+ ready = await client.separations.wait(separation.id)
73
+ print(ready.duration)
74
+
75
+
76
+ asyncio.run(main())
77
+ ```
78
+
79
+ ### Follow its progress
80
+
81
+ ```python
82
+ from disband import Queued
83
+
84
+ for state in client.separations.watch(separation.id):
85
+ match state:
86
+ case Queued(position=int(position)):
87
+ print(f"{position} in line")
88
+ case _:
89
+ print(state.status)
90
+
91
+ # it has ended, so this returns at once, or raises the error it failed with
92
+ ready = client.separations.wait(separation.id)
93
+ ```
94
+
95
+ ### Handle errors
96
+
97
+ `wait` raises the error a separation failed with, the same one a create raises when the API refuses the file.
98
+
99
+ ```python
100
+ from disband import AudioError, OutOfCreditsError
101
+
102
+ try:
103
+ separation = client.separations.create("song.mp3", stems=["vocals"])
104
+ ready = client.separations.wait(separation.id)
105
+ except OutOfCreditsError as error:
106
+ print(error.detail)
107
+ except AudioError:
108
+ print("The file couldn't be decoded")
109
+ ```
110
+
111
+ ### Upload from a user's browser
112
+
113
+ Reserve the upload on your server, then hand the upload URL to the browser. The key stays on your server, and the
114
+ file never passes through it.
115
+
116
+ ```python
117
+ @app.post("/uploads")
118
+ async def reserve(size: int) -> Uploading:
119
+ return await client.separations.reserve(
120
+ size, stems=["vocals", "instrumental"], webhook="https://example.com/hooks/disband"
121
+ )
122
+ ```
123
+
124
+ ```js
125
+ // in the browser, with the upload_url from your server
126
+ await fetch(upload_url, { method: "PUT", body: file });
127
+ ```
128
+
129
+ The separation starts once the upload is complete.
130
+
131
+ ### Receive a webhook
132
+
133
+ ```python
134
+ from disband import WebhookVerificationError, verify_webhook
135
+
136
+
137
+ # reads DISBAND_WEBHOOK_SECRET
138
+ @app.post("/hooks/disband")
139
+ async def hook(request: Request) -> Response:
140
+ try:
141
+ separation = verify_webhook(await request.body(), request.headers)
142
+ except WebhookVerificationError:
143
+ return Response(status_code=400)
144
+ return Response(status_code=204)
145
+ ```
146
+
147
+ ### Pass a stem on
148
+
149
+ The stream stays open while its `with` block runs, so a response that streams later opens it in its own generator.
150
+
151
+ ```python
152
+ async def chunks(file: StemFile) -> AsyncIterator[bytes]:
153
+ async with client.stream(file) as stem:
154
+ async for chunk in stem:
155
+ yield chunk
156
+
157
+
158
+ @app.get("/stems/{separation_id}/vocals")
159
+ async def vocals(separation_id: str) -> StreamingResponse:
160
+ ready = await client.separations.wait(separation_id)
161
+ # silent stems have no files
162
+ if (mp3 := ready.stems["vocals"].mp3) is None:
163
+ raise HTTPException(404)
164
+ return StreamingResponse(chunks(mp3), media_type="audio/mpeg")
165
+ ```
166
+
167
+ ## Requirements
168
+
169
+ - Python 3.11 or later
170
+ - asyncio or Trio for `AsyncDisband`
171
+
172
+ ## Docs
173
+
174
+ [disband.io/docs](https://disband.io/docs)
@@ -0,0 +1,154 @@
1
+ <p align="center">
2
+ <img src="https://disband.io/favicon.svg" alt="" width="128">
3
+ </p>
4
+
5
+ <h1 align="center">Disband</h1>
6
+
7
+ <p align="center">
8
+ Python SDK for the stem separation API at <a href="https://disband.io">disband.io</a>
9
+ <br><br>
10
+ <a href="https://pypi.org/project/disband/"><img src="https://img.shields.io/pypi/v/disband?color=blue" alt="Version"></a>
11
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/disbandio/disband-python?color=blue" alt="License"></a>
12
+ </p>
13
+
14
+ ## Usage
15
+
16
+ ```sh
17
+ pip install disband
18
+ ```
19
+
20
+ Create a key on [API keys](https://disband.io/app/keys) and set it as `DISBAND_KEY`.
21
+
22
+ ## Examples
23
+
24
+ ### Split a song
25
+
26
+ ```python
27
+ from disband import Disband
28
+
29
+ # reads DISBAND_KEY
30
+ with Disband() as client:
31
+ separation = client.separations.create("song.mp3", stems=["vocals", "instrumental"], formats=["mp3"])
32
+ ready = client.separations.wait(separation.id)
33
+
34
+ for stem, files in ready.stems.items():
35
+ # silent stems have no files
36
+ if files.mp3 is not None:
37
+ client.download(files.mp3, f"{stem}.mp3")
38
+ ```
39
+
40
+ ### Async
41
+
42
+ ```python
43
+ import asyncio
44
+
45
+ from disband import AsyncDisband
46
+
47
+
48
+ async def main() -> None:
49
+ async with AsyncDisband() as client:
50
+ # one stem or several
51
+ separation = await client.separations.create("song.mp3", stems="vocals")
52
+ ready = await client.separations.wait(separation.id)
53
+ print(ready.duration)
54
+
55
+
56
+ asyncio.run(main())
57
+ ```
58
+
59
+ ### Follow its progress
60
+
61
+ ```python
62
+ from disband import Queued
63
+
64
+ for state in client.separations.watch(separation.id):
65
+ match state:
66
+ case Queued(position=int(position)):
67
+ print(f"{position} in line")
68
+ case _:
69
+ print(state.status)
70
+
71
+ # it has ended, so this returns at once, or raises the error it failed with
72
+ ready = client.separations.wait(separation.id)
73
+ ```
74
+
75
+ ### Handle errors
76
+
77
+ `wait` raises the error a separation failed with, the same one a create raises when the API refuses the file.
78
+
79
+ ```python
80
+ from disband import AudioError, OutOfCreditsError
81
+
82
+ try:
83
+ separation = client.separations.create("song.mp3", stems=["vocals"])
84
+ ready = client.separations.wait(separation.id)
85
+ except OutOfCreditsError as error:
86
+ print(error.detail)
87
+ except AudioError:
88
+ print("The file couldn't be decoded")
89
+ ```
90
+
91
+ ### Upload from a user's browser
92
+
93
+ Reserve the upload on your server, then hand the upload URL to the browser. The key stays on your server, and the
94
+ file never passes through it.
95
+
96
+ ```python
97
+ @app.post("/uploads")
98
+ async def reserve(size: int) -> Uploading:
99
+ return await client.separations.reserve(
100
+ size, stems=["vocals", "instrumental"], webhook="https://example.com/hooks/disband"
101
+ )
102
+ ```
103
+
104
+ ```js
105
+ // in the browser, with the upload_url from your server
106
+ await fetch(upload_url, { method: "PUT", body: file });
107
+ ```
108
+
109
+ The separation starts once the upload is complete.
110
+
111
+ ### Receive a webhook
112
+
113
+ ```python
114
+ from disband import WebhookVerificationError, verify_webhook
115
+
116
+
117
+ # reads DISBAND_WEBHOOK_SECRET
118
+ @app.post("/hooks/disband")
119
+ async def hook(request: Request) -> Response:
120
+ try:
121
+ separation = verify_webhook(await request.body(), request.headers)
122
+ except WebhookVerificationError:
123
+ return Response(status_code=400)
124
+ return Response(status_code=204)
125
+ ```
126
+
127
+ ### Pass a stem on
128
+
129
+ The stream stays open while its `with` block runs, so a response that streams later opens it in its own generator.
130
+
131
+ ```python
132
+ async def chunks(file: StemFile) -> AsyncIterator[bytes]:
133
+ async with client.stream(file) as stem:
134
+ async for chunk in stem:
135
+ yield chunk
136
+
137
+
138
+ @app.get("/stems/{separation_id}/vocals")
139
+ async def vocals(separation_id: str) -> StreamingResponse:
140
+ ready = await client.separations.wait(separation_id)
141
+ # silent stems have no files
142
+ if (mp3 := ready.stems["vocals"].mp3) is None:
143
+ raise HTTPException(404)
144
+ return StreamingResponse(chunks(mp3), media_type="audio/mpeg")
145
+ ```
146
+
147
+ ## Requirements
148
+
149
+ - Python 3.11 or later
150
+ - asyncio or Trio for `AsyncDisband`
151
+
152
+ ## Docs
153
+
154
+ [disband.io/docs](https://disband.io/docs)
@@ -0,0 +1,77 @@
1
+ [project]
2
+ name = "disband"
3
+ version = "0.1.1"
4
+ description = "Python client for the Disband stem separation API"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.11"
9
+ keywords = [
10
+ "stem separation",
11
+ "vocal remover",
12
+ "audio",
13
+ "music",
14
+ "api",
15
+ ]
16
+ classifiers = [
17
+ "Framework :: AnyIO",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Multimedia :: Sound/Audio",
21
+ "Typing :: Typed",
22
+ ]
23
+ dependencies = [
24
+ "anyio>=4.10,<5",
25
+ "httpx2>=2.16,<3",
26
+ "pydantic>=2.7,<3",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://disband.io/docs"
31
+ Repository = "https://github.com/disbandio/disband-python"
32
+
33
+ [build-system]
34
+ requires = ["uv_build>=0.12.24,<0.13.0"]
35
+ build-backend = "uv_build"
36
+
37
+ [dependency-groups]
38
+ dev = [
39
+ "anyio>=4.11",
40
+ "basedpyright>=1.40.2",
41
+ "pytest>=9.2.0",
42
+ "ruff>=0.17.6",
43
+ "setuptools>=84.2.1",
44
+ "standardwebhooks>=1.3.0",
45
+ "unasync>=0.6.0",
46
+ ]
47
+
48
+ [tool.ruff]
49
+ line-length = 120
50
+
51
+ [tool.ruff.lint]
52
+ extend-select = [
53
+ "I",
54
+ "UP",
55
+ "B",
56
+ "A",
57
+ "SIM",
58
+ "RUF",
59
+ ]
60
+
61
+ [tool.ruff.lint.per-file-ignores]
62
+ "**/_sync/*" = ["UP028"]
63
+
64
+ [tool.basedpyright]
65
+ typeCheckingMode = "strict"
66
+ pythonVersion = "3.11"
67
+ venvPath = "."
68
+ venv = ".venv"
69
+ include = [
70
+ "src",
71
+ "tests",
72
+ "scripts",
73
+ ]
74
+
75
+ [tool.pytest.ini_options]
76
+ testpaths = ["tests"]
77
+ anyio_mode = "auto"
@@ -0,0 +1,63 @@
1
+ [project]
2
+ name = "disband"
3
+ version = "0.1.1"
4
+ description = "Python client for the Disband stem separation API"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.11"
9
+ keywords = ["stem separation", "vocal remover", "audio", "music", "api"]
10
+ classifiers = [
11
+ "Framework :: AnyIO",
12
+ "Intended Audience :: Developers",
13
+ "Programming Language :: Python :: 3",
14
+ "Topic :: Multimedia :: Sound/Audio",
15
+ "Typing :: Typed",
16
+ ]
17
+ dependencies = [
18
+ "anyio>=4.10,<5",
19
+ "httpx2>=2.16,<3",
20
+ # 2.7 reads attribute docstrings as field descriptions
21
+ "pydantic>=2.7,<3",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://disband.io/docs"
26
+ Repository = "https://github.com/disbandio/disband-python"
27
+
28
+ [build-system]
29
+ requires = ["uv_build>=0.12.24,<0.13.0"]
30
+ build-backend = "uv_build"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "anyio>=4.11",
35
+ "basedpyright>=1.40.2",
36
+ "pytest>=9.2.0",
37
+ "ruff>=0.17.6",
38
+ "setuptools>=84.2.1",
39
+ "standardwebhooks>=1.3.0",
40
+ "unasync>=0.6.0",
41
+ ]
42
+
43
+ [tool.ruff]
44
+ line-length = 120
45
+
46
+ [tool.ruff.lint]
47
+ extend-select = ["I", "UP", "B", "A", "SIM", "RUF"]
48
+
49
+ [tool.ruff.lint.per-file-ignores]
50
+ # a generated loop over a page, where the async source can't use yield from
51
+ "**/_sync/*" = ["UP028"]
52
+
53
+ [tool.basedpyright]
54
+ typeCheckingMode = "strict"
55
+ pythonVersion = "3.11"
56
+ venvPath = "."
57
+ venv = ".venv"
58
+ include = ["src", "tests", "scripts"]
59
+
60
+ [tool.pytest.ini_options]
61
+ testpaths = ["tests"]
62
+ # the async tests run without a marker, which their generated sync copies would carry too
63
+ anyio_mode = "auto"
@@ -0,0 +1,88 @@
1
+ from ._async import AsyncDisband, AsyncSeparations, AsyncStemStream
2
+ from ._errors import (
3
+ APIError,
4
+ AudioError,
5
+ AuthenticationError,
6
+ BadRequestError,
7
+ BusyError,
8
+ ConflictError,
9
+ DisbandError,
10
+ NetworkError,
11
+ NotFoundError,
12
+ OutOfCreditsError,
13
+ PermissionDeniedError,
14
+ RequestTimeoutError,
15
+ ServerError,
16
+ UploadExpiredError,
17
+ WaitTimeoutError,
18
+ WebhookVerificationError,
19
+ )
20
+ from ._models import (
21
+ Catalog,
22
+ Credits,
23
+ Failed,
24
+ Failure,
25
+ FieldError,
26
+ Format,
27
+ Limits,
28
+ Problem,
29
+ ProblemType,
30
+ Processing,
31
+ Queued,
32
+ Ready,
33
+ Separation,
34
+ Stem,
35
+ StemFile,
36
+ StemFiles,
37
+ StemId,
38
+ Uploading,
39
+ Usage,
40
+ )
41
+ from ._sync import Disband, Separations, StemStream
42
+ from ._webhooks import verify_webhook, webhook_secret
43
+
44
+ __all__ = [
45
+ "APIError",
46
+ "AsyncDisband",
47
+ "AsyncSeparations",
48
+ "AsyncStemStream",
49
+ "AudioError",
50
+ "AuthenticationError",
51
+ "BadRequestError",
52
+ "BusyError",
53
+ "Catalog",
54
+ "ConflictError",
55
+ "Credits",
56
+ "Disband",
57
+ "DisbandError",
58
+ "Failed",
59
+ "Failure",
60
+ "FieldError",
61
+ "Format",
62
+ "Limits",
63
+ "NetworkError",
64
+ "NotFoundError",
65
+ "OutOfCreditsError",
66
+ "PermissionDeniedError",
67
+ "Problem",
68
+ "ProblemType",
69
+ "Processing",
70
+ "Queued",
71
+ "Ready",
72
+ "RequestTimeoutError",
73
+ "Separation",
74
+ "Separations",
75
+ "ServerError",
76
+ "Stem",
77
+ "StemFile",
78
+ "StemFiles",
79
+ "StemId",
80
+ "StemStream",
81
+ "UploadExpiredError",
82
+ "Uploading",
83
+ "Usage",
84
+ "WaitTimeoutError",
85
+ "WebhookVerificationError",
86
+ "verify_webhook",
87
+ "webhook_secret",
88
+ ]
@@ -0,0 +1,5 @@
1
+ from ._client import AsyncDisband
2
+ from ._separations import AsyncSeparations
3
+ from ._stream import AsyncStemStream
4
+
5
+ __all__ = ["AsyncDisband", "AsyncSeparations", "AsyncStemStream"]