audioexport 0.1.0__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.
- audioexport-0.1.0/LICENSE +201 -0
- audioexport-0.1.0/MANIFEST.in +12 -0
- audioexport-0.1.0/PKG-INFO +226 -0
- audioexport-0.1.0/README.md +196 -0
- audioexport-0.1.0/audioexport/__init__.py +44 -0
- audioexport-0.1.0/audioexport/__main__.py +4 -0
- audioexport-0.1.0/audioexport/_version.py +24 -0
- audioexport-0.1.0/audioexport/api.py +36 -0
- audioexport-0.1.0/audioexport/chapters.py +159 -0
- audioexport-0.1.0/audioexport/cli.py +141 -0
- audioexport-0.1.0/audioexport/errors.py +25 -0
- audioexport-0.1.0/audioexport/fftools.py +278 -0
- audioexport-0.1.0/audioexport/formats.py +83 -0
- audioexport-0.1.0/audioexport/pipeline.py +728 -0
- audioexport-0.1.0/audioexport/profile.py +212 -0
- audioexport-0.1.0/audioexport/py.typed +0 -0
- audioexport-0.1.0/audioexport.egg-info/SOURCES.txt +21 -0
- audioexport-0.1.0/docs/changelog.md +15 -0
- audioexport-0.1.0/docs/readio-migration.md +63 -0
- audioexport-0.1.0/examples/chapters.json +6 -0
- audioexport-0.1.0/examples/create_demo_wav.py +28 -0
- audioexport-0.1.0/examples/export.toml +42 -0
- audioexport-0.1.0/pyproject.toml +60 -0
- audioexport-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include LICENSE README.md pyproject.toml
|
|
2
|
+
recursive-include audioexport *.py py.typed
|
|
3
|
+
recursive-include docs *.md
|
|
4
|
+
recursive-include examples *.py *.toml *.json
|
|
5
|
+
prune .github
|
|
6
|
+
prune .ledger
|
|
7
|
+
prune tests
|
|
8
|
+
prune audioexport.egg-info
|
|
9
|
+
prune scripts
|
|
10
|
+
exclude .codecrate.toml .gitignore .pre-commit-config.yaml
|
|
11
|
+
global-exclude __pycache__ *.py[cod]
|
|
12
|
+
exclude 01_audioexport.md plan.md plan.revision.md
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: audioexport
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Standalone FFmpeg audio encoder with metadata, chapter, cover and reproducible export manifests
|
|
5
|
+
Author: audioexport contributors
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: ffmpeg,audio,mp3,m4a,flac,m4b,opus
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: tomli>=2; python_version < "3.11"
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
26
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
27
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
28
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# audioexport
|
|
32
|
+
|
|
33
|
+
An independent Python library and command-line interface for exporting audio through **FFmpeg**. This is the first extraction step from Readio's output/encoding subsystem, but **audioexport does not import or install Readio, AudioCompose, UtterPlan, or synthesis engines**.
|
|
34
|
+
|
|
35
|
+
Supported formats: WAV (PCM16), FLAC, MP3, M4A (AAC), M4B (AAC audiobook), OGG (Vorbis), and Opus. Handles tagged metadata, embedded JPEG/PNG cover art for MP3/M4A/M4B, JSON chapter timelines for M4A/M4B, FFprobe verification, artifact identities and safe reuse.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
Requirements: **Python 3.10+** and external **FFmpeg + FFprobe** executables available on `PATH`. Install a build containing the encoders you need: `pcm_s16le`, `flac`, `libmp3lame`, `aac`, `libvorbis` (or native `vorbis`), and/or `libopus`.
|
|
40
|
+
|
|
41
|
+
Platform notes:
|
|
42
|
+
|
|
43
|
+
- Ubuntu/Debian: `sudo apt-get install ffmpeg`.
|
|
44
|
+
- macOS: `brew install ffmpeg`.
|
|
45
|
+
- Windows: install a current FFmpeg build and add its `bin` directory to `PATH`.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python -m pip install audioexport
|
|
49
|
+
python -m audioexport --version
|
|
50
|
+
# Or install from a checkout:
|
|
51
|
+
python -m pip install -e .
|
|
52
|
+
audioexport doctor --json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`doctor` reports package/tool versions and encoder availability per format. Its existing `ready` key means FFmpeg and FFprobe are present; `all_formats_ready` and each `formats` entry report encoder capability and a reason when unavailable. `run_profile()` checks the encoders selected by the profile before writing outputs.
|
|
56
|
+
|
|
57
|
+
The only base Python dependency is `tomli` on Python 3.10. FFmpeg/FFprobe are external executables; AudioExport does not install or import Readio, AudioCompose, UtterPlan, VoiceRender, soundfile, or NumPy.
|
|
58
|
+
|
|
59
|
+
## CLI quickstart
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Creates demo.wav in the current directory (or use your own audio file):
|
|
63
|
+
python examples/create_demo_wav.py
|
|
64
|
+
# Any FFmpeg-decodable audio source is accepted.
|
|
65
|
+
audioexport encode demo.wav --format mp3 -o output.mp3 --bitrate 192k
|
|
66
|
+
audioexport encode demo.wav --format flac -o output.flac
|
|
67
|
+
audioexport encode demo.wav --format m4a -o output.m4a --title "My recording" --artist "An author"
|
|
68
|
+
audioexport encode demo.wav --format ogg -o output.ogg
|
|
69
|
+
audioexport encode demo.wav --format opus -o output.opus
|
|
70
|
+
|
|
71
|
+
audioexport inspect output.mp3 --json
|
|
72
|
+
audioexport doctor --json
|
|
73
|
+
|
|
74
|
+
# For M4B chapters; use your own cover.jpg or omit --cover:
|
|
75
|
+
audioexport encode demo.wav --format m4b -o mybook.m4b \
|
|
76
|
+
--title "My Book" --artist "An Author" \
|
|
77
|
+
--timeline examples/chapters.json --cover cover.jpg --bitrate 192k
|
|
78
|
+
|
|
79
|
+
# Export multiple formats at once using an editable profile:
|
|
80
|
+
audioexport run demo.wav --profile examples/export.toml --out-dir exported/ --json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If `--output` is not set for `encode`, the output filename defaults to the input stem and chosen format. To avoid destroying the input, encoding input and output to the same real path is always rejected.
|
|
84
|
+
|
|
85
|
+
Without `--force`, an untracked, symlink, or manually modified output is never overwritten. A previously generated output is updated when its sidecar and checksum still match; re-running identical options returns `reused: true` without re-encoding. `--force` authorizes replacing an unknown or modified regular file, but symlink outputs and sidecars are always rejected. Writes are staged with their manifest; a failed manifest commit restores the last good pair when possible, and an incomplete recovery reports the preserved backup path. A per-target process lock rejects concurrent writers with `audioexport.output_busy`; remove a stale lock only after confirming no writer is active.
|
|
86
|
+
|
|
87
|
+
OGG defaults to Vorbis quality-based encoding (`-qscale:a 4`) to avoid low-rate/mono bitrate incompatibilities. `--bitrate` accepts values such as `192k`, `192000`, or `1M`; whitespace is trimmed. A bare integer is interpreted as **bits per second**, so use `192k` (or `192000`), not `192`, for a nominal 192 kb/s rate. WAV/FLAC don't accept bitrate. WAV output is always PCM16 conversion, not a byte-for-byte passthrough; lossy codecs and even PCM output can vary with FFmpeg versions, which are included in the export identity.
|
|
88
|
+
|
|
89
|
+
## Python API
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import audioexport
|
|
93
|
+
from pathlib import Path
|
|
94
|
+
from audioexport import Chapter, encode, run_profile, doctor, probe
|
|
95
|
+
|
|
96
|
+
result = encode(
|
|
97
|
+
Path("master.wav"),
|
|
98
|
+
Path("exported/book.m4b"),
|
|
99
|
+
format="m4b", bitrate="192k",
|
|
100
|
+
metadata={"title": "My Book", "artist": "Author Name"},
|
|
101
|
+
cover=Path("cover.jpg"),
|
|
102
|
+
chapters=[
|
|
103
|
+
Chapter("Introduction", start_ms=0),
|
|
104
|
+
Chapter("Chapter One", start_ms=60_000),
|
|
105
|
+
],
|
|
106
|
+
)
|
|
107
|
+
print(result.to_dict())
|
|
108
|
+
|
|
109
|
+
for other in run_profile("master.wav", "examples/export.toml", "exported"):
|
|
110
|
+
print(other.path, other.reused)
|
|
111
|
+
|
|
112
|
+
print(audioexport.__version__)
|
|
113
|
+
diagnostics = doctor()
|
|
114
|
+
print(diagnostics["ready"], diagnostics["all_formats_ready"])
|
|
115
|
+
print(probe("exported/book.m4b")["chapters"])
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You may import the same public functions from `audioexport.api` as well as from `audioexport`.
|
|
119
|
+
|
|
120
|
+
The public errors are `AudioExportError` and subclasses `InvalidExportError`, `ToolNotFoundError`, `EncodingError`, and `VerificationError`, with a stable machine-readable `.code` value. `encode()` returns an immutable `ExportResult` containing the identity, path, checksum, and reuse state. Both `encode` and `run_profile` work without a Readio project.
|
|
121
|
+
|
|
122
|
+
## Export profile
|
|
123
|
+
|
|
124
|
+
[`examples/export.toml`](examples/export.toml) is a complete seven-format example. The `audioexport.profile.v1` schema keeps profile-wide `cover`, `timeline`, and `[metadata]`, while each `[[outputs]]` row may add `use_cover` and `use_chapters`:
|
|
125
|
+
|
|
126
|
+
```toml
|
|
127
|
+
schema = "audioexport.profile.v1"
|
|
128
|
+
timeline = "chapters.json" # resolved relative to this TOML
|
|
129
|
+
# cover = "cover.jpg" # optional; uncomment and provide the file
|
|
130
|
+
|
|
131
|
+
[metadata]
|
|
132
|
+
title = "My audiobook"
|
|
133
|
+
artist = "An author"
|
|
134
|
+
album = "My audiobook"
|
|
135
|
+
|
|
136
|
+
[[outputs]]
|
|
137
|
+
format = "mp3"
|
|
138
|
+
bitrate = "192k"
|
|
139
|
+
use_cover = false
|
|
140
|
+
use_chapters = false
|
|
141
|
+
|
|
142
|
+
[[outputs]]
|
|
143
|
+
format = "flac"
|
|
144
|
+
use_cover = false
|
|
145
|
+
use_chapters = false
|
|
146
|
+
|
|
147
|
+
[[outputs]]
|
|
148
|
+
format = "m4a"
|
|
149
|
+
bitrate = "192k"
|
|
150
|
+
use_chapters = true
|
|
151
|
+
|
|
152
|
+
[[outputs]]
|
|
153
|
+
format = "m4b"
|
|
154
|
+
bitrate = "192k"
|
|
155
|
+
use_chapters = true
|
|
156
|
+
|
|
157
|
+
[[outputs]]
|
|
158
|
+
format = "ogg"
|
|
159
|
+
|
|
160
|
+
[[outputs]]
|
|
161
|
+
format = "opus"
|
|
162
|
+
bitrate = "96k"
|
|
163
|
+
|
|
164
|
+
[[outputs]]
|
|
165
|
+
format = "wav"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
When a selector is omitted (`None`), configured global artwork is attached automatically only to MP3/M4A/M4B, and chapters only to M4A/M4B; unsupported formats skip those global resources. `true` requires the resource and a capable format; `false` suppresses it. For example, to enable artwork, set a valid top-level `cover` and `use_cover = true` on the MP3/M4A/M4B rows. Direct `encode()` calls remain strict: unsupported cover/chapter arguments are errors.
|
|
169
|
+
|
|
170
|
+
`run_profile()` validates every row, resource, capability, and concrete filename collision before the first encode, then returns results in TOML order. Resource paths are relative to the profile file. Explicit `filename` values are literal simple filenames with the matching extension; no template expansion or nested paths are supported. If omitted, each filename uses the input stem. Profile-wide metadata is inherited by every output; there is no per-output metadata override.
|
|
171
|
+
|
|
172
|
+
## Chapters/timeline
|
|
173
|
+
|
|
174
|
+
Use an independent JSON file such as [`examples/chapters.json`](examples/chapters.json):
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"chapters": [
|
|
179
|
+
{ "title": "Intro", "start_ms": 0 },
|
|
180
|
+
{ "title": "Part One", "start_ms": 60000 }
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`end_ms` is optional; without it, chapter ends are the next chapter start or the audio duration. Chapter offsets must be strictly increasing and within the audio file. FFmpeg metadata escaping is handled internally. Embedded chapter markers are currently supported for **M4A and M4B**.
|
|
186
|
+
|
|
187
|
+
For an incremental Readio migration, the same `--timeline` API also reads **Readio's `readio.composition-timeline` JSON** with `sample_rate` and chapter `start_sample`. FFmetadata is constructed with its original sample timebase for precision, with generic millisecond chapter fields available for non-Readio workflows.
|
|
188
|
+
|
|
189
|
+
## Integrity and versioning
|
|
190
|
+
|
|
191
|
+
Each completed output has a sibling sidecar, for example `output.mp3.audioexport.json`, holding `audioexport.manifest.v1`, a SHA-256 export identity, the source/output and consumed-resource digests, FFmpeg/FFprobe versions, normalized options, chapter mapping, and probed output summary. The identity is **input-content + relevant options/resources + tools**, not output location or TOML formatting. A bitrate change affects only that output; a timeline change affects only chapter-consuming outputs; changing shared metadata affects all outputs that inherit it. The original source is never modified.
|
|
192
|
+
|
|
193
|
+
Encoding uses argument-vector subprocess calls (`shell=False`) and stages both audio and manifest before committing. The output lock serializes same-target writers across processes; a competing call receives a typed busy error. If a sidecar commit fails, the previous output/manifest are restored when possible. A recovery failure retains its backup and refuses to treat a mismatched sidecar as current; inspect the reported recovery path before retrying. FFprobe validation checks the single audio stream, codec, duration, requested tags/chapters, and cover codec/disposition.
|
|
194
|
+
|
|
195
|
+
Version is dynamic through `setuptools-scm`: `pyproject.toml` has no static `version` field, and Git tags determine wheel/sdist metadata, `audioexport.__version__`, and CLI output. The project supports Python 3.10+ and retains the flat `audioexport/` layout. Unversioned archives use a development fallback; a fallback build must never be treated as final `0.1.0`.
|
|
196
|
+
|
|
197
|
+
For a release, first commit the code and wait for the complete Linux/Windows/macOS, Python 3.10/3.13 CI matrix. Then create and push the intended version tag (for example `v0.1.0`). Manually dispatch `.github/workflows/release.yml` with that existing tag. It reruns the test matrix, checks the tag against wheel/sdist metadata, inspects package contents, installs the wheel outside the checkout, and checks CLI/API version parity. Publishing uses PyPI trusted publishing only after the `pypi` GitHub environment is approved; repository administrators must configure required reviewers for that environment and register the trusted publisher on PyPI. Do not publish from an untagged/fallback build.
|
|
198
|
+
|
|
199
|
+
## Readio migration
|
|
200
|
+
|
|
201
|
+
**Readio is deliberately not patched by this project.** Its existing export commands continue using their current code until an opt-in bridge is tested. A future integration must call AudioExport's Python library API; it must never launch the `audioexport` CLI as a subprocess. See [`docs/readio-migration.md`](docs/readio-migration.md) for the compatibility boundary, integration order, and rollback rules. Readio continues owning project locks, path defaults, staleness, indexed state, and orchestration.
|
|
202
|
+
|
|
203
|
+
## Tests
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
python -m pip install -e '.[dev]'
|
|
207
|
+
python -m pytest -q
|
|
208
|
+
ruff check .
|
|
209
|
+
ruff format --check .
|
|
210
|
+
mypy audioexport
|
|
211
|
+
python -m compileall -q audioexport
|
|
212
|
+
python -m build
|
|
213
|
+
python -m twine check dist/*
|
|
214
|
+
python scripts/check_package_artifacts.py
|
|
215
|
+
audioexport doctor --json
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Tests cover seven real formats in one profile, selective cache invalidation, M4A/M4B chapters and covers, Readio sample timelines, malformed probes, encoder availability, transactional failure recovery, no-clobber behavior, and concurrent writers. CI runs Python 3.10 and 3.13 on Linux, Windows, and macOS, and checks lint, formatting, typing, build metadata, Twine, package contents, and an isolated wheel install outside the checkout. Cross-platform encoder availability still depends on the FFmpeg build installed by the runner.
|
|
219
|
+
|
|
220
|
+
## Limitations (MVP)
|
|
221
|
+
|
|
222
|
+
No audio mastering, TTS, audio mixing, streaming PCM API, FFmpeg filter graphs, network service, or GUI. No automatic conversion of Readio project configs, legacy export cache, or Audiocompose timeline semantics other than chapter starts. Encoder output may vary across FFmpeg versions; the cache key includes tool versions. Chapter verification has a small tolerance for FFmpeg container timebase rounding. Standalone encoding does not modify Readio projects.
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
Apache-2.0. The FFmpeg executable is a separate third-party program distributed under its own terms.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# audioexport
|
|
2
|
+
|
|
3
|
+
An independent Python library and command-line interface for exporting audio through **FFmpeg**. This is the first extraction step from Readio's output/encoding subsystem, but **audioexport does not import or install Readio, AudioCompose, UtterPlan, or synthesis engines**.
|
|
4
|
+
|
|
5
|
+
Supported formats: WAV (PCM16), FLAC, MP3, M4A (AAC), M4B (AAC audiobook), OGG (Vorbis), and Opus. Handles tagged metadata, embedded JPEG/PNG cover art for MP3/M4A/M4B, JSON chapter timelines for M4A/M4B, FFprobe verification, artifact identities and safe reuse.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Requirements: **Python 3.10+** and external **FFmpeg + FFprobe** executables available on `PATH`. Install a build containing the encoders you need: `pcm_s16le`, `flac`, `libmp3lame`, `aac`, `libvorbis` (or native `vorbis`), and/or `libopus`.
|
|
10
|
+
|
|
11
|
+
Platform notes:
|
|
12
|
+
|
|
13
|
+
- Ubuntu/Debian: `sudo apt-get install ffmpeg`.
|
|
14
|
+
- macOS: `brew install ffmpeg`.
|
|
15
|
+
- Windows: install a current FFmpeg build and add its `bin` directory to `PATH`.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
python -m pip install audioexport
|
|
19
|
+
python -m audioexport --version
|
|
20
|
+
# Or install from a checkout:
|
|
21
|
+
python -m pip install -e .
|
|
22
|
+
audioexport doctor --json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`doctor` reports package/tool versions and encoder availability per format. Its existing `ready` key means FFmpeg and FFprobe are present; `all_formats_ready` and each `formats` entry report encoder capability and a reason when unavailable. `run_profile()` checks the encoders selected by the profile before writing outputs.
|
|
26
|
+
|
|
27
|
+
The only base Python dependency is `tomli` on Python 3.10. FFmpeg/FFprobe are external executables; AudioExport does not install or import Readio, AudioCompose, UtterPlan, VoiceRender, soundfile, or NumPy.
|
|
28
|
+
|
|
29
|
+
## CLI quickstart
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Creates demo.wav in the current directory (or use your own audio file):
|
|
33
|
+
python examples/create_demo_wav.py
|
|
34
|
+
# Any FFmpeg-decodable audio source is accepted.
|
|
35
|
+
audioexport encode demo.wav --format mp3 -o output.mp3 --bitrate 192k
|
|
36
|
+
audioexport encode demo.wav --format flac -o output.flac
|
|
37
|
+
audioexport encode demo.wav --format m4a -o output.m4a --title "My recording" --artist "An author"
|
|
38
|
+
audioexport encode demo.wav --format ogg -o output.ogg
|
|
39
|
+
audioexport encode demo.wav --format opus -o output.opus
|
|
40
|
+
|
|
41
|
+
audioexport inspect output.mp3 --json
|
|
42
|
+
audioexport doctor --json
|
|
43
|
+
|
|
44
|
+
# For M4B chapters; use your own cover.jpg or omit --cover:
|
|
45
|
+
audioexport encode demo.wav --format m4b -o mybook.m4b \
|
|
46
|
+
--title "My Book" --artist "An Author" \
|
|
47
|
+
--timeline examples/chapters.json --cover cover.jpg --bitrate 192k
|
|
48
|
+
|
|
49
|
+
# Export multiple formats at once using an editable profile:
|
|
50
|
+
audioexport run demo.wav --profile examples/export.toml --out-dir exported/ --json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If `--output` is not set for `encode`, the output filename defaults to the input stem and chosen format. To avoid destroying the input, encoding input and output to the same real path is always rejected.
|
|
54
|
+
|
|
55
|
+
Without `--force`, an untracked, symlink, or manually modified output is never overwritten. A previously generated output is updated when its sidecar and checksum still match; re-running identical options returns `reused: true` without re-encoding. `--force` authorizes replacing an unknown or modified regular file, but symlink outputs and sidecars are always rejected. Writes are staged with their manifest; a failed manifest commit restores the last good pair when possible, and an incomplete recovery reports the preserved backup path. A per-target process lock rejects concurrent writers with `audioexport.output_busy`; remove a stale lock only after confirming no writer is active.
|
|
56
|
+
|
|
57
|
+
OGG defaults to Vorbis quality-based encoding (`-qscale:a 4`) to avoid low-rate/mono bitrate incompatibilities. `--bitrate` accepts values such as `192k`, `192000`, or `1M`; whitespace is trimmed. A bare integer is interpreted as **bits per second**, so use `192k` (or `192000`), not `192`, for a nominal 192 kb/s rate. WAV/FLAC don't accept bitrate. WAV output is always PCM16 conversion, not a byte-for-byte passthrough; lossy codecs and even PCM output can vary with FFmpeg versions, which are included in the export identity.
|
|
58
|
+
|
|
59
|
+
## Python API
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import audioexport
|
|
63
|
+
from pathlib import Path
|
|
64
|
+
from audioexport import Chapter, encode, run_profile, doctor, probe
|
|
65
|
+
|
|
66
|
+
result = encode(
|
|
67
|
+
Path("master.wav"),
|
|
68
|
+
Path("exported/book.m4b"),
|
|
69
|
+
format="m4b", bitrate="192k",
|
|
70
|
+
metadata={"title": "My Book", "artist": "Author Name"},
|
|
71
|
+
cover=Path("cover.jpg"),
|
|
72
|
+
chapters=[
|
|
73
|
+
Chapter("Introduction", start_ms=0),
|
|
74
|
+
Chapter("Chapter One", start_ms=60_000),
|
|
75
|
+
],
|
|
76
|
+
)
|
|
77
|
+
print(result.to_dict())
|
|
78
|
+
|
|
79
|
+
for other in run_profile("master.wav", "examples/export.toml", "exported"):
|
|
80
|
+
print(other.path, other.reused)
|
|
81
|
+
|
|
82
|
+
print(audioexport.__version__)
|
|
83
|
+
diagnostics = doctor()
|
|
84
|
+
print(diagnostics["ready"], diagnostics["all_formats_ready"])
|
|
85
|
+
print(probe("exported/book.m4b")["chapters"])
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
You may import the same public functions from `audioexport.api` as well as from `audioexport`.
|
|
89
|
+
|
|
90
|
+
The public errors are `AudioExportError` and subclasses `InvalidExportError`, `ToolNotFoundError`, `EncodingError`, and `VerificationError`, with a stable machine-readable `.code` value. `encode()` returns an immutable `ExportResult` containing the identity, path, checksum, and reuse state. Both `encode` and `run_profile` work without a Readio project.
|
|
91
|
+
|
|
92
|
+
## Export profile
|
|
93
|
+
|
|
94
|
+
[`examples/export.toml`](examples/export.toml) is a complete seven-format example. The `audioexport.profile.v1` schema keeps profile-wide `cover`, `timeline`, and `[metadata]`, while each `[[outputs]]` row may add `use_cover` and `use_chapters`:
|
|
95
|
+
|
|
96
|
+
```toml
|
|
97
|
+
schema = "audioexport.profile.v1"
|
|
98
|
+
timeline = "chapters.json" # resolved relative to this TOML
|
|
99
|
+
# cover = "cover.jpg" # optional; uncomment and provide the file
|
|
100
|
+
|
|
101
|
+
[metadata]
|
|
102
|
+
title = "My audiobook"
|
|
103
|
+
artist = "An author"
|
|
104
|
+
album = "My audiobook"
|
|
105
|
+
|
|
106
|
+
[[outputs]]
|
|
107
|
+
format = "mp3"
|
|
108
|
+
bitrate = "192k"
|
|
109
|
+
use_cover = false
|
|
110
|
+
use_chapters = false
|
|
111
|
+
|
|
112
|
+
[[outputs]]
|
|
113
|
+
format = "flac"
|
|
114
|
+
use_cover = false
|
|
115
|
+
use_chapters = false
|
|
116
|
+
|
|
117
|
+
[[outputs]]
|
|
118
|
+
format = "m4a"
|
|
119
|
+
bitrate = "192k"
|
|
120
|
+
use_chapters = true
|
|
121
|
+
|
|
122
|
+
[[outputs]]
|
|
123
|
+
format = "m4b"
|
|
124
|
+
bitrate = "192k"
|
|
125
|
+
use_chapters = true
|
|
126
|
+
|
|
127
|
+
[[outputs]]
|
|
128
|
+
format = "ogg"
|
|
129
|
+
|
|
130
|
+
[[outputs]]
|
|
131
|
+
format = "opus"
|
|
132
|
+
bitrate = "96k"
|
|
133
|
+
|
|
134
|
+
[[outputs]]
|
|
135
|
+
format = "wav"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
When a selector is omitted (`None`), configured global artwork is attached automatically only to MP3/M4A/M4B, and chapters only to M4A/M4B; unsupported formats skip those global resources. `true` requires the resource and a capable format; `false` suppresses it. For example, to enable artwork, set a valid top-level `cover` and `use_cover = true` on the MP3/M4A/M4B rows. Direct `encode()` calls remain strict: unsupported cover/chapter arguments are errors.
|
|
139
|
+
|
|
140
|
+
`run_profile()` validates every row, resource, capability, and concrete filename collision before the first encode, then returns results in TOML order. Resource paths are relative to the profile file. Explicit `filename` values are literal simple filenames with the matching extension; no template expansion or nested paths are supported. If omitted, each filename uses the input stem. Profile-wide metadata is inherited by every output; there is no per-output metadata override.
|
|
141
|
+
|
|
142
|
+
## Chapters/timeline
|
|
143
|
+
|
|
144
|
+
Use an independent JSON file such as [`examples/chapters.json`](examples/chapters.json):
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"chapters": [
|
|
149
|
+
{ "title": "Intro", "start_ms": 0 },
|
|
150
|
+
{ "title": "Part One", "start_ms": 60000 }
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`end_ms` is optional; without it, chapter ends are the next chapter start or the audio duration. Chapter offsets must be strictly increasing and within the audio file. FFmpeg metadata escaping is handled internally. Embedded chapter markers are currently supported for **M4A and M4B**.
|
|
156
|
+
|
|
157
|
+
For an incremental Readio migration, the same `--timeline` API also reads **Readio's `readio.composition-timeline` JSON** with `sample_rate` and chapter `start_sample`. FFmetadata is constructed with its original sample timebase for precision, with generic millisecond chapter fields available for non-Readio workflows.
|
|
158
|
+
|
|
159
|
+
## Integrity and versioning
|
|
160
|
+
|
|
161
|
+
Each completed output has a sibling sidecar, for example `output.mp3.audioexport.json`, holding `audioexport.manifest.v1`, a SHA-256 export identity, the source/output and consumed-resource digests, FFmpeg/FFprobe versions, normalized options, chapter mapping, and probed output summary. The identity is **input-content + relevant options/resources + tools**, not output location or TOML formatting. A bitrate change affects only that output; a timeline change affects only chapter-consuming outputs; changing shared metadata affects all outputs that inherit it. The original source is never modified.
|
|
162
|
+
|
|
163
|
+
Encoding uses argument-vector subprocess calls (`shell=False`) and stages both audio and manifest before committing. The output lock serializes same-target writers across processes; a competing call receives a typed busy error. If a sidecar commit fails, the previous output/manifest are restored when possible. A recovery failure retains its backup and refuses to treat a mismatched sidecar as current; inspect the reported recovery path before retrying. FFprobe validation checks the single audio stream, codec, duration, requested tags/chapters, and cover codec/disposition.
|
|
164
|
+
|
|
165
|
+
Version is dynamic through `setuptools-scm`: `pyproject.toml` has no static `version` field, and Git tags determine wheel/sdist metadata, `audioexport.__version__`, and CLI output. The project supports Python 3.10+ and retains the flat `audioexport/` layout. Unversioned archives use a development fallback; a fallback build must never be treated as final `0.1.0`.
|
|
166
|
+
|
|
167
|
+
For a release, first commit the code and wait for the complete Linux/Windows/macOS, Python 3.10/3.13 CI matrix. Then create and push the intended version tag (for example `v0.1.0`). Manually dispatch `.github/workflows/release.yml` with that existing tag. It reruns the test matrix, checks the tag against wheel/sdist metadata, inspects package contents, installs the wheel outside the checkout, and checks CLI/API version parity. Publishing uses PyPI trusted publishing only after the `pypi` GitHub environment is approved; repository administrators must configure required reviewers for that environment and register the trusted publisher on PyPI. Do not publish from an untagged/fallback build.
|
|
168
|
+
|
|
169
|
+
## Readio migration
|
|
170
|
+
|
|
171
|
+
**Readio is deliberately not patched by this project.** Its existing export commands continue using their current code until an opt-in bridge is tested. A future integration must call AudioExport's Python library API; it must never launch the `audioexport` CLI as a subprocess. See [`docs/readio-migration.md`](docs/readio-migration.md) for the compatibility boundary, integration order, and rollback rules. Readio continues owning project locks, path defaults, staleness, indexed state, and orchestration.
|
|
172
|
+
|
|
173
|
+
## Tests
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
python -m pip install -e '.[dev]'
|
|
177
|
+
python -m pytest -q
|
|
178
|
+
ruff check .
|
|
179
|
+
ruff format --check .
|
|
180
|
+
mypy audioexport
|
|
181
|
+
python -m compileall -q audioexport
|
|
182
|
+
python -m build
|
|
183
|
+
python -m twine check dist/*
|
|
184
|
+
python scripts/check_package_artifacts.py
|
|
185
|
+
audioexport doctor --json
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Tests cover seven real formats in one profile, selective cache invalidation, M4A/M4B chapters and covers, Readio sample timelines, malformed probes, encoder availability, transactional failure recovery, no-clobber behavior, and concurrent writers. CI runs Python 3.10 and 3.13 on Linux, Windows, and macOS, and checks lint, formatting, typing, build metadata, Twine, package contents, and an isolated wheel install outside the checkout. Cross-platform encoder availability still depends on the FFmpeg build installed by the runner.
|
|
189
|
+
|
|
190
|
+
## Limitations (MVP)
|
|
191
|
+
|
|
192
|
+
No audio mastering, TTS, audio mixing, streaming PCM API, FFmpeg filter graphs, network service, or GUI. No automatic conversion of Readio project configs, legacy export cache, or Audiocompose timeline semantics other than chapter starts. Encoder output may vary across FFmpeg versions; the cache key includes tool versions. Chapter verification has a small tolerance for FFmpeg container timebase rounding. Standalone encoding does not modify Readio projects.
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
Apache-2.0. The FFmpeg executable is a separate third-party program distributed under its own terms.
|