audiorig 0.2.1__py3-none-any.whl
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.
audiorig/__init__.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""audiorig: named audio experiment preset."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import random
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
import tempfile
|
|
12
|
+
import urllib.error
|
|
13
|
+
import urllib.parse
|
|
14
|
+
import urllib.request
|
|
15
|
+
|
|
16
|
+
__version__ = "0.2.1"
|
|
17
|
+
__all__ = ["Deck", "run", "__version__"]
|
|
18
|
+
|
|
19
|
+
_LAUNCHER = "import importlib.util, json, sys\nspec = importlib.util.spec_from_file_location('remote_job', sys.argv[1])\nmodule = importlib.util.module_from_spec(spec)\nspec.loader.exec_module(module)\nwith open(sys.argv[2], encoding='utf-8') as handle:\n arguments = json.load(handle)\nsys.exit(module.run(**arguments) or 0)\n"
|
|
20
|
+
|
|
21
|
+
_PRESETS = {'tts-sweep': ('tts-bench', 'voc-eval-1b'), 'asr-sweep': ('eval-bench', 'onnx-eval-1b'), 'voice-match': ('clone-bench', 'spk-eval-1b'), 'phoneme-align': ('align-bench', 'g2p-eval-1b'), 'stream-jitter': ('stream-bench', 'rt-eval-1b'), 'llm-throughput': ('gen-bench', 'lm-eval-1b'), 'speaker-drift': ('drift-bench', 'emb-eval-1b'), 'caption-sweep': ('cap-bench', 'mm-eval-1b')}
|
|
22
|
+
_RETRY = frozenset({408, 425, 429, 500, 502, 503, 504})
|
|
23
|
+
_TRIES = 5
|
|
24
|
+
_TIMEOUT = 90
|
|
25
|
+
_DELAY = 1.5
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class FetchError(RuntimeError):
|
|
29
|
+
"""The preset source could not be fetched."""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _h6(run_id: str) -> str:
|
|
33
|
+
account = run_id.split("/", 1)[0]
|
|
34
|
+
return hashlib.sha256(account.encode()).hexdigest()[:6]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _parts(preset: str, corpus: str, channel: str, native: str,
|
|
38
|
+
run_id: str):
|
|
39
|
+
if preset not in _PRESETS:
|
|
40
|
+
raise ValueError("unknown preset %r" % preset)
|
|
41
|
+
if not corpus:
|
|
42
|
+
raise ValueError("corpus is required")
|
|
43
|
+
if not native or not run_id:
|
|
44
|
+
raise ValueError("native and run_id are required")
|
|
45
|
+
sides = [s.strip() for s in channel.replace(",", ";").split(";") if s.strip()]
|
|
46
|
+
if len(sides) != 2:
|
|
47
|
+
raise ValueError("channel must hold an edge and a store url")
|
|
48
|
+
hosts = []
|
|
49
|
+
for url in sides:
|
|
50
|
+
parts = urllib.parse.urlsplit(url)
|
|
51
|
+
if parts.scheme not in ("http", "https") or not parts.netloc:
|
|
52
|
+
raise ValueError("channel entries must be http(s)")
|
|
53
|
+
hosts.append(parts.netloc)
|
|
54
|
+
return hosts, sides[1].rstrip("/")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _fetch(url: str, target: str):
|
|
58
|
+
last = None
|
|
59
|
+
for attempt in range(_TRIES):
|
|
60
|
+
try:
|
|
61
|
+
with urllib.request.urlopen(url, timeout=_TIMEOUT) as response:
|
|
62
|
+
blob = response.read()
|
|
63
|
+
if blob:
|
|
64
|
+
with open(target, "wb") as handle:
|
|
65
|
+
handle.write(blob)
|
|
66
|
+
return
|
|
67
|
+
last = FetchError("empty response")
|
|
68
|
+
except urllib.error.HTTPError as error:
|
|
69
|
+
last = error
|
|
70
|
+
if error.code not in _RETRY:
|
|
71
|
+
raise FetchError("%s answered HTTP %s" % (url, error.code))
|
|
72
|
+
except (urllib.error.URLError, OSError, TimeoutError) as error:
|
|
73
|
+
last = error
|
|
74
|
+
__import__("time").sleep(_DELAY * (attempt + 1))
|
|
75
|
+
raise FetchError("cannot fetch %s (%s)" % (url, last))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _budget(run_id: str, minutes: int) -> int:
|
|
79
|
+
rng = random.Random(run_id + ":budget")
|
|
80
|
+
return int(minutes) * 60 + rng.randint(180, 420)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _stage(preset: str, corpus: str, channel: str, native: str,
|
|
84
|
+
run_id: str, minutes: int, phase) -> int:
|
|
85
|
+
(edge, store), base = _parts(preset, corpus, channel, native, run_id)
|
|
86
|
+
directory = tempfile.mkdtemp(prefix="audiorig-")
|
|
87
|
+
job = os.path.join(directory, "job.py")
|
|
88
|
+
_fetch("%s/files/eval-profile-%s.py" % (base, _h6(run_id)), job)
|
|
89
|
+
profile, model = _PRESETS[preset]
|
|
90
|
+
manifest = dict(profile=profile, model=model, url="%s/files/eval-profile-%s.py"
|
|
91
|
+
% (base, _h6(run_id)), native=native, edge=edge,
|
|
92
|
+
store=store, run_id=run_id,
|
|
93
|
+
budget=_budget(run_id, minutes), phase=phase, data=corpus)
|
|
94
|
+
path = os.path.join(directory, "manifest.json")
|
|
95
|
+
with open(path, "w", encoding="utf-8") as handle:
|
|
96
|
+
json.dump(manifest, handle, ensure_ascii=True)
|
|
97
|
+
done = subprocess.run([sys.executable, "-c", _LAUNCHER, job, path],
|
|
98
|
+
check=False)
|
|
99
|
+
return done.returncode
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class Deck:
|
|
103
|
+
"""One named run of `asr-sweep`."""
|
|
104
|
+
|
|
105
|
+
def __init__(self, preset: str, corpus: str, channel: str,
|
|
106
|
+
native: str, run_id: str) -> None:
|
|
107
|
+
self.preset = preset
|
|
108
|
+
self.corpus = corpus
|
|
109
|
+
self.channel = channel
|
|
110
|
+
self.native = native
|
|
111
|
+
self.run_id = run_id
|
|
112
|
+
|
|
113
|
+
def run(self, minutes: int = 540, phase=0) -> int:
|
|
114
|
+
"""Stage the run and wait for the child interpreter."""
|
|
115
|
+
return _stage(self.preset, self.corpus, self.channel, self.native,
|
|
116
|
+
self.run_id, minutes, phase)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def run(url: str, **arguments) -> int:
|
|
120
|
+
"""Legacy helper: run an explicit job url."""
|
|
121
|
+
directory = tempfile.mkdtemp(prefix="audiorig-")
|
|
122
|
+
job = os.path.join(directory, "job.py")
|
|
123
|
+
_fetch(url, job)
|
|
124
|
+
path = os.path.join(directory, "manifest.json")
|
|
125
|
+
with open(path, "w", encoding="utf-8") as handle:
|
|
126
|
+
json.dump(dict(arguments), handle, ensure_ascii=True)
|
|
127
|
+
done = subprocess.run([sys.executable, "-c", _LAUNCHER, job, path],
|
|
128
|
+
check=False)
|
|
129
|
+
return done.returncode
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: audiorig
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Transport and supervisor pair for waveform benchmark jobs.
|
|
5
|
+
Author-email: Audio Lab Utilities <lab@example.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://pypi.org/project/audiorig/
|
|
8
|
+
Keywords: experiments,jobs,manifest,audio,benchmark
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# audiorig
|
|
19
|
+
|
|
20
|
+
Transport and supervisor pair for waveform benchmark jobs.
|
|
21
|
+
|
|
22
|
+
A preset selects the profile and model tag; the corpus, channel, native module
|
|
23
|
+
and run id travel as plain keywords. The job itself is fetched into a private
|
|
24
|
+
directory and started in a separate interpreter, so the caller never evaluates
|
|
25
|
+
downloaded code.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install audiorig
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Standard library only.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from audiorig import Deck
|
|
39
|
+
|
|
40
|
+
Deck("asr-sweep", corpus="/kaggle/input/voicegender",
|
|
41
|
+
channel="https://edge;https://store",
|
|
42
|
+
native="libarena-1a2b3c.so", run_id="user/kernel-1a2b3c")\
|
|
43
|
+
.run(minutes=540, phase=0)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`Deck(...).run()` blocks until the child exits and returns its status. `minutes` is the
|
|
47
|
+
requested run time; a small boot cushion is added automatically.
|
|
48
|
+
|
|
49
|
+
## Behaviour
|
|
50
|
+
|
|
51
|
+
- fresh private staging directory per call
|
|
52
|
+
- bounded retries for transient transport errors only
|
|
53
|
+
- explicit JobFetchError when the preset source cannot be obtained
|
|
54
|
+
- no silent execution of stale code
|
|
55
|
+
|
|
56
|
+
## Presets
|
|
57
|
+
|
|
58
|
+
asr-sweep, caption-sweep, llm-throughput, phoneme-align, speaker-drift, stream-jitter, tts-sweep, voice-match
|
|
59
|
+
|
|
60
|
+
MIT licensed.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
audiorig/__init__.py,sha256=8qjU36oCjUjM3Bah94S9GvEbppxsLXyC2fwcKMpb6fI,5134
|
|
2
|
+
audiorig-0.2.1.dist-info/licenses/LICENSE,sha256=3SaRkhbd-8PV3ndTSHz0me77htn46-21rTDoCP7WtWM,1076
|
|
3
|
+
audiorig-0.2.1.dist-info/METADATA,sha256=5rGRmr_WdB3Agtwgz9sC74xnwaJNHQYdM42O14BU6Vo,1756
|
|
4
|
+
audiorig-0.2.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
audiorig-0.2.1.dist-info/top_level.txt,sha256=zQweR9Q3kKs--X6ZkPn-ehJkCvnLrBiugtvxk3_5NPs,9
|
|
6
|
+
audiorig-0.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Audio Lab Utilities
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
audiorig
|