tinkerbox-ane 2.2.0__tar.gz → 2.3.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.
- tinkerbox_ane-2.3.0/.git-blame-ignore-revs +2 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/.github/workflows/publish.yml +2 -2
- tinkerbox_ane-2.3.0/.swift-format +81 -0
- tinkerbox_ane-2.3.0/LICENSES/GPT-2-MIT.txt +24 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/NOTICE +12 -0
- tinkerbox_ane-2.3.0/PKG-INFO +75 -0
- tinkerbox_ane-2.3.0/README.md +50 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/AudioPlayback.swift +32 -23
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/AudioRecording.swift +11 -7
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Catalog.swift +113 -82
- tinkerbox_ane-2.3.0/app/Completion.swift +357 -0
- tinkerbox_ane-2.3.0/app/Decision.swift +748 -0
- tinkerbox_ane-2.3.0/app/Demo.swift +790 -0
- tinkerbox_ane-2.3.0/app/Home.swift +80 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/LogoActivity.swift +75 -20
- tinkerbox_ane-2.3.0/app/Models.swift +290 -0
- tinkerbox_ane-2.3.0/app/README.md +92 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Runtime.swift +253 -202
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Shortcuts.swift +215 -151
- tinkerbox_ane-2.3.0/app/Speech.swift +588 -0
- tinkerbox_ane-2.3.0/app/Storage.swift +486 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/run.py +122 -41
- tinkerbox_ane-2.3.0/app/smoke.py +74 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/worker.py +68 -30
- tinkerbox_ane-2.3.0/docs/cache-cleanup.md +21 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/docs/cow-staging.md +1 -1
- tinkerbox_ane-2.3.0/docs/model-publishing.md +105 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/docs/models/d1.md +4 -4
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/docs/models/d3.md +3 -4
- tinkerbox_ane-2.3.0/docs/models/gpt2.md +50 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/docs/models/omnivoice.md +3 -3
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/docs/models/voxcpm2.md +2 -2
- tinkerbox_ane-2.3.0/docs/releasing.md +13 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/docs/speech.md +8 -15
- tinkerbox_ane-2.3.0/hatch_build.py +57 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/pyproject.toml +5 -1
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/scripts/build_reference.py +68 -23
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/scripts/clean_coreai.py +22 -17
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/scripts/omnivoice/reference_logits.py +20 -14
- tinkerbox_ane-2.3.0/scripts/omnivoice/speech_case.py +33 -0
- tinkerbox_ane-2.3.0/scripts/omnivoice/validate_context.py +130 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/scripts/release.py +13 -2
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/scripts/validate.py +25 -10
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/scripts/validate_d3.py +169 -75
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/scripts/voxcpm2/full_length.py +51 -30
- tinkerbox_ane-2.3.0/scripts/voxcpm2/gate.py +77 -0
- tinkerbox_ane-2.3.0/scripts/voxcpm2/reference.py +157 -0
- tinkerbox_ane-2.3.0/scripts/voxcpm2/validate.py +153 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/architectures/attention.py +3 -3
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/architectures/dac.py +15 -12
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/architectures/gpt2.py +129 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/architectures/minicpm.py +34 -19
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/architectures/qwen3.py +41 -22
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/audio.py +4 -4
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/audio.swift +35 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/bidirectional.swift +198 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/blocks.py +1 -3
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/bundle.py +87 -92
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/cached.swift +159 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/chunked.swift +259 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/compile.py +22 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/completion.py +44 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/coreai.py +87 -11
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/cow-staging.m +3 -9
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d1/__init__.py +26 -12
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d1/export.py +47 -52
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d1/model.py +53 -29
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d1/runtime.py +61 -28
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d1/tree.py +4 -4
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d1/validation.py +27 -10
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d1/vision.py +31 -19
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d3/__init__.py +33 -11
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d3/export.py +55 -21
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d3/model.py +36 -17
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d3/runtime.py +49 -54
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/d3/vision.py +58 -31
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/download.py +4 -2
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/generation.py +282 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/gpt2/__init__.py +44 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/gpt2/export.py +156 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/gpt2/runtime.py +124 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/guard.py +40 -20
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/host.py +44 -84
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/host.swift +454 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/models.json +499 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/models.py +13 -7
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/omnivoice/__init__.py +42 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/omnivoice/export.py +271 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/omnivoice/parameters.py +61 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/omnivoice/runtime.py +103 -61
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/publish.py +105 -55
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/speech.py +192 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/staged.swift +223 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/storage.py +82 -29
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/tokenization.py +28 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/transcription.py +6 -6
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/transcription.swift +13 -7
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/validation.py +1 -1
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/voxcpm2/__init__.py +41 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/voxcpm2/codec.py +27 -11
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/voxcpm2/export.py +281 -0
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/voxcpm2/parameters.py +60 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/voxcpm2/prompt.py +13 -11
- tinkerbox_ane-2.3.0/src/tinkerbox_ane/voxcpm2/runtime.py +532 -0
- tinkerbox_ane-2.3.0/tests/conftest.py +19 -0
- tinkerbox_ane-2.3.0/tests/swiftui/CompletionSmoke.swift +117 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/swiftui/ShortcutsSmoke.swift +42 -29
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/swiftui/SpeechModeSmoke.swift +7 -5
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/swiftui/SpeechShortcutsSmoke.swift +26 -15
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/swiftui/SpeechSmoke.swift +60 -42
- tinkerbox_ane-2.3.0/tests/swiftui/TokenHighlightSmoke.swift +80 -0
- tinkerbox_ane-2.3.0/tests/swiftui/VoxCPM2SpeechSmoke.swift +66 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/test_clean_coreai.py +13 -7
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/test_d3_runtime.py +29 -30
- tinkerbox_ane-2.3.0/tests/test_gpt2_generation.py +200 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/test_guard.py +4 -4
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/test_publish.py +94 -49
- tinkerbox_ane-2.3.0/tests/test_runtime.py +249 -0
- tinkerbox_ane-2.3.0/tests/test_speech.py +202 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/tests/test_storage.py +36 -20
- tinkerbox_ane-2.3.0/tests/test_voxcpm2_speech.py +137 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/uv.lock +3 -1
- tinkerbox_ane-2.2.0/PKG-INFO +0 -136
- tinkerbox_ane-2.2.0/README.md +0 -113
- tinkerbox_ane-2.2.0/app/Demo.swift +0 -1317
- tinkerbox_ane-2.2.0/app/README.md +0 -166
- tinkerbox_ane-2.2.0/app/Speech.swift +0 -488
- tinkerbox_ane-2.2.0/app/Storage.swift +0 -305
- tinkerbox_ane-2.2.0/app/test_shortcuts.py +0 -45
- tinkerbox_ane-2.2.0/app/test_speech.py +0 -31
- tinkerbox_ane-2.2.0/app/test_voxcpm2_speech.py +0 -29
- tinkerbox_ane-2.2.0/docs/cache-cleanup.md +0 -48
- tinkerbox_ane-2.2.0/docs/model-publishing.md +0 -162
- tinkerbox_ane-2.2.0/docs/releasing.md +0 -20
- tinkerbox_ane-2.2.0/hatch_build.py +0 -34
- tinkerbox_ane-2.2.0/scripts/omnivoice/speech_case.py +0 -31
- tinkerbox_ane-2.2.0/scripts/omnivoice/validate_context.py +0 -105
- tinkerbox_ane-2.2.0/scripts/publish_all_chips.py +0 -7
- tinkerbox_ane-2.2.0/scripts/voxcpm2/gate.py +0 -64
- tinkerbox_ane-2.2.0/scripts/voxcpm2/reference.py +0 -115
- tinkerbox_ane-2.2.0/scripts/voxcpm2/validate.py +0 -120
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/audio.swift +0 -32
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/bidirectional.swift +0 -162
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/cached.swift +0 -130
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/chunked.swift +0 -263
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/d1/compile.py +0 -38
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/d1/guard.py +0 -7
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/d1/publish.py +0 -81
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/d3/compile.py +0 -38
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/d3/publish.py +0 -58
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/host.swift +0 -500
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/models.json +0 -237
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/omnivoice/__init__.py +0 -31
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/omnivoice/export.py +0 -210
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/omnivoice/parameters.py +0 -36
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/omnivoice/publish.py +0 -12
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/speech.py +0 -166
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/staged.swift +0 -219
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/voxcpm2/__init__.py +0 -29
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/voxcpm2/export.py +0 -217
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/voxcpm2/parameters.py +0 -30
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/voxcpm2/publish.py +0 -13
- tinkerbox_ane-2.2.0/src/tinkerbox_ane/voxcpm2/runtime.py +0 -428
- tinkerbox_ane-2.2.0/tests/swiftui/VoxCPM2SpeechSmoke.swift +0 -53
- tinkerbox_ane-2.2.0/tests/test_runtime.py +0 -223
- tinkerbox_ane-2.2.0/tests/test_speech.py +0 -140
- tinkerbox_ane-2.2.0/tests/test_voxcpm2_speech.py +0 -105
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/.gitignore +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/AGENTS.md +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/LICENSES/Apache-2.0.txt +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/LICENSES/LFM-Open-License-v1.0.txt +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/LICENSES/VoxCPM-Apache-2.0.txt +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/LICENSE-uv.txt +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Tinkerbox.icon/Assets/Glow.svg +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Tinkerbox.icon/Assets/Long 1.svg +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Tinkerbox.icon/Assets/Long 2.svg +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Tinkerbox.icon/Assets/Nodes.svg +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Tinkerbox.icon/Assets/Short.svg +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/app/Tinkerbox.icon/icon.json +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/__init__.py +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/architectures/__init__.py +0 -0
- {tinkerbox_ane-2.2.0 → tinkerbox_ane-2.3.0}/src/tinkerbox_ane/install.py +0 -0
|
@@ -4,7 +4,7 @@ on:
|
|
|
4
4
|
workflow_dispatch:
|
|
5
5
|
inputs:
|
|
6
6
|
tag:
|
|
7
|
-
description: Release tag to publish (
|
|
7
|
+
description: Release tag to publish (e.g., v1.0.0)
|
|
8
8
|
required: true
|
|
9
9
|
type: string
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ jobs:
|
|
|
23
23
|
with:
|
|
24
24
|
ref: refs/tags/${{ inputs.tag }}
|
|
25
25
|
persist-credentials: false
|
|
26
|
-
- uses: astral-sh/setup-uv@v10
|
|
26
|
+
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
27
27
|
with:
|
|
28
28
|
version: "0.11.28"
|
|
29
29
|
- name: Check release version and model bundles
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fileScopedDeclarationPrivacy": {
|
|
3
|
+
"accessLevel": "private"
|
|
4
|
+
},
|
|
5
|
+
"indentBlankLines": false,
|
|
6
|
+
"indentConditionalCompilationBlocks": true,
|
|
7
|
+
"indentSwitchCaseLabels": false,
|
|
8
|
+
"indentation": {
|
|
9
|
+
"spaces": 4
|
|
10
|
+
},
|
|
11
|
+
"lineBreakAroundMultilineExpressionChainComponents": false,
|
|
12
|
+
"lineBreakBeforeControlFlowKeywords": false,
|
|
13
|
+
"lineBreakBeforeEachArgument": false,
|
|
14
|
+
"lineBreakBeforeEachGenericRequirement": false,
|
|
15
|
+
"lineBreakBetweenDeclarationAttributes": false,
|
|
16
|
+
"lineLength": 120,
|
|
17
|
+
"maximumBlankLines": 1,
|
|
18
|
+
"multiElementCollectionTrailingCommas": true,
|
|
19
|
+
"multilineTrailingCommaBehavior": "keptAsWritten",
|
|
20
|
+
"noAssignmentInExpressions": {
|
|
21
|
+
"allowedFunctions": [
|
|
22
|
+
"XCTAssertNoThrow"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"orderedImports": {
|
|
26
|
+
"includeConditionalImports": false,
|
|
27
|
+
"shouldGroupImports": true
|
|
28
|
+
},
|
|
29
|
+
"prioritizeKeepingFunctionOutputTogether": false,
|
|
30
|
+
"reflowMultilineStringLiterals": "never",
|
|
31
|
+
"respectsExistingLineBreaks": true,
|
|
32
|
+
"rules": {
|
|
33
|
+
"AllPublicDeclarationsHaveDocumentation": false,
|
|
34
|
+
"AlwaysUseLiteralForEmptyCollectionInit": false,
|
|
35
|
+
"AlwaysUseLowerCamelCase": false,
|
|
36
|
+
"AmbiguousTrailingClosureOverload": false,
|
|
37
|
+
"AvoidRetroactiveConformances": false,
|
|
38
|
+
"BeginDocumentationCommentWithOneLineSummary": false,
|
|
39
|
+
"DoNotUseSemicolons": false,
|
|
40
|
+
"DontRepeatTypeInStaticProperties": false,
|
|
41
|
+
"FileScopedDeclarationPrivacy": false,
|
|
42
|
+
"FullyIndirectEnum": false,
|
|
43
|
+
"GroupNumericLiterals": false,
|
|
44
|
+
"IdentifiersMustBeASCII": false,
|
|
45
|
+
"NeverForceUnwrap": false,
|
|
46
|
+
"NeverUseForceTry": false,
|
|
47
|
+
"NeverUseImplicitlyUnwrappedOptionals": false,
|
|
48
|
+
"NoAccessLevelOnExtensionDeclaration": false,
|
|
49
|
+
"NoAssignmentInExpressions": false,
|
|
50
|
+
"NoBlockComments": false,
|
|
51
|
+
"NoCasesWithOnlyFallthrough": false,
|
|
52
|
+
"NoEmptyLinesOpeningClosingBraces": false,
|
|
53
|
+
"NoEmptyTrailingClosureParentheses": false,
|
|
54
|
+
"NoLabelsInCasePatterns": false,
|
|
55
|
+
"NoLeadingUnderscores": false,
|
|
56
|
+
"NoParensAroundConditions": false,
|
|
57
|
+
"NoPlaygroundLiterals": false,
|
|
58
|
+
"NoVoidReturnOnFunctionSignature": false,
|
|
59
|
+
"OmitExplicitReturns": false,
|
|
60
|
+
"OneCasePerLine": false,
|
|
61
|
+
"OneVariableDeclarationPerLine": false,
|
|
62
|
+
"OnlyOneTrailingClosureArgument": false,
|
|
63
|
+
"OrderedImports": false,
|
|
64
|
+
"ReplaceForEachWithForLoop": false,
|
|
65
|
+
"ReturnVoidInsteadOfEmptyTuple": false,
|
|
66
|
+
"TypeNamesShouldBeCapitalized": false,
|
|
67
|
+
"UseEarlyExits": false,
|
|
68
|
+
"UseExplicitNilCheckInConditions": false,
|
|
69
|
+
"UseLetInEveryBoundCaseVariable": false,
|
|
70
|
+
"UseShorthandTypeNames": false,
|
|
71
|
+
"UseSingleLinePropertyGetter": false,
|
|
72
|
+
"UseSynthesizedInitializer": false,
|
|
73
|
+
"UseTripleSlashForDocumentationComments": false,
|
|
74
|
+
"UseWhereClausesInForLoops": false,
|
|
75
|
+
"ValidateDocumentationComments": false
|
|
76
|
+
},
|
|
77
|
+
"spacesAroundRangeFormationOperators": false,
|
|
78
|
+
"spacesBeforeEndOfLineComments": 2,
|
|
79
|
+
"tabWidth": 8,
|
|
80
|
+
"version": 1
|
|
81
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Modified MIT License
|
|
2
|
+
|
|
3
|
+
Software Copyright (c) 2019 OpenAI
|
|
4
|
+
|
|
5
|
+
We don’t claim ownership of the content you create with GPT-2, so it is yours to do with as you please.
|
|
6
|
+
We only ask that you use GPT-2 responsibly and clearly indicate your content was created using GPT-2.
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
9
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
10
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
11
|
+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
12
|
+
subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included
|
|
15
|
+
in all copies or substantial portions of the Software.
|
|
16
|
+
The above copyright notice and this permission notice need not be included
|
|
17
|
+
with content created by the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
20
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
22
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
24
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -42,3 +42,15 @@ Copyright 2026 OpenBMB. Code and weights are Apache-2.0 licensed;
|
|
|
42
42
|
see LICENSES/VoxCPM-Apache-2.0.txt. The AudioVAE V2 codec and causal streaming decoder
|
|
43
43
|
are retained from upstream. MiniCPM transformers are independently converted
|
|
44
44
|
for ANE; task conditioning and sampling follow the pinned upstream contract.
|
|
45
|
+
|
|
46
|
+
GPT-2 text-completion integration:
|
|
47
|
+
Upstream: https://github.com/openai/gpt-2
|
|
48
|
+
Checkpoints: https://huggingface.co/openai-community/gpt2 and the
|
|
49
|
+
gpt2-medium, gpt2-large and gpt2-xl repositories in the same organization.
|
|
50
|
+
Software Copyright (c) 2019 OpenAI. See LICENSES/GPT-2-MIT.txt for the
|
|
51
|
+
original Modified MIT License. Checkpoint revisions are pinned in
|
|
52
|
+
src/tinkerbox_ane/gpt2/__init__.py and recorded in exported manifests.
|
|
53
|
+
The shared decoder runs with FP16 activations and optional INT8 or LUT8 projection
|
|
54
|
+
weights in Core AI functions on ANE. Tokenization, learned position and token
|
|
55
|
+
embeddings, tied vocabulary readout and sampling
|
|
56
|
+
run on the CPU. The models have not been retrained.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tinkerbox-ane
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: Optimized AI model runtime for practical tasks on Apple Neural Engine.
|
|
5
|
+
Project-URL: Homepage, https://github.com/WeGoToMars/tinkerbox
|
|
6
|
+
Project-URL: Issues, https://github.com/WeGoToMars/tinkerbox/issues
|
|
7
|
+
License-File: LICENSES/Apache-2.0.txt
|
|
8
|
+
License-File: LICENSES/GPT-2-MIT.txt
|
|
9
|
+
License-File: LICENSES/LFM-Open-License-v1.0.txt
|
|
10
|
+
License-File: LICENSES/VoxCPM-Apache-2.0.txt
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Requires-Python: <3.14,>=3.12
|
|
13
|
+
Requires-Dist: huggingface-hub==2.2.0
|
|
14
|
+
Requires-Dist: numpy==2.4.6
|
|
15
|
+
Requires-Dist: pillow>=10.0.0
|
|
16
|
+
Requires-Dist: regex==2026.9.29
|
|
17
|
+
Requires-Dist: safetensors==0.8.0
|
|
18
|
+
Requires-Dist: torch==2.9.0
|
|
19
|
+
Requires-Dist: torchvision==0.24.0
|
|
20
|
+
Requires-Dist: transformers==5.19.0
|
|
21
|
+
Provides-Extra: speech
|
|
22
|
+
Requires-Dist: omnivoice==0.2.1; extra == 'speech'
|
|
23
|
+
Requires-Dist: torchaudio==2.9.0; extra == 'speech'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
<img width="1920" height="388" alt="banner" src="https://github.com/user-attachments/assets/52cfb1e7-c841-4898-9a94-d199db85f2d7" />
|
|
27
|
+
|
|
28
|
+
# Tinkerbox for Apple Neural Engine
|
|
29
|
+
|
|
30
|
+
Run models on Apple's Neural Engine through Core AI. Inference runs on the Neural Engine, the CPU handles tokenization and other light work, and the GPU stays idle.
|
|
31
|
+
|
|
32
|
+
| Model | Task | Chips | Notes |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| [LiquidAI/d1-3B](https://huggingface.co/LiquidAI/d1-3B) (`d1-3b`) | Decisions over text and images, several questions per pass | M4–M6 | [d1.md](docs/models/d1.md) |
|
|
35
|
+
| [vllm-sr/d3-nano](https://huggingface.co/vllm-sr/d3-nano), [d3-mini](https://huggingface.co/vllm-sr/d3-mini) (`d3-nano`, `d3-mini`) | Decisions over text and images | M4–M6 | [d3.md](docs/models/d3.md) |
|
|
36
|
+
| [k2-fsa/OmniVoice](https://huggingface.co/k2-fsa/OmniVoice) (`omnivoice`) | Speech, voice design and cloning | M4–M6 | [omnivoice.md](docs/models/omnivoice.md) |
|
|
37
|
+
| [openbmb/VoxCPM2](https://huggingface.co/openbmb/VoxCPM2) (`voxcpm2`, `voxcpm2-lut8`) | Speech, voice design, cloning and continuation | M1–M6 | [voxcpm2.md](docs/models/voxcpm2.md) |
|
|
38
|
+
| [openai-community/gpt2](https://huggingface.co/openai-community/gpt2) (`gpt2`, `gpt2-medium`, `gpt2-large`, `gpt2-xl`) | Text completion | M1–M6 | [gpt2.md](docs/models/gpt2.md) |
|
|
39
|
+
|
|
40
|
+
Requires macOS 27 on Apple Silicon.
|
|
41
|
+
|
|
42
|
+
## App
|
|
43
|
+
|
|
44
|
+
Download `Tinkerbox-ANE-*-macos-arm64.zip` from the [latest release](https://github.com/WeGoToMars/tinkerbox/releases/latest), move **Tinkerbox.app** to Applications and open it. It sets up its own Python environment and downloads each model the first time you select it. Its tasks are also available as Shortcuts actions. See the [app guide](app/README.md).
|
|
45
|
+
|
|
46
|
+
## Python
|
|
47
|
+
|
|
48
|
+
Python 3.12 or 3.13:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
python -m pip install tinkerbox-ane # add [speech] for OmniVoice and VoxCPM2
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import tinkerbox_ane
|
|
56
|
+
|
|
57
|
+
with tinkerbox_ane.load("d1-3b") as model:
|
|
58
|
+
result = model.system_one(
|
|
59
|
+
"I was charged twice this month.",
|
|
60
|
+
{"refund": {"type": "noul", "instructions": "Is this a refund request?"}},
|
|
61
|
+
)
|
|
62
|
+
print(result["answers"])
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`tinkerbox_ane.load(model_id)` downloads the Core AI bundle for this Mac to `~/Library/Caches/tinkerbox-ane/models/` and returns the API for the model's task. Pass a directory as the second argument to load a local bundle instead. Bundles include the tokenizer, configuration and the few weights that run on the CPU, so loading never downloads the upstream checkpoint.
|
|
66
|
+
|
|
67
|
+
- **Decisions** (d1, d3): `system_one`, `system_one_batch`, `probabilities`, `probabilities_batch` and `count_tokens` answer yes/no (`noul`), `choice` and `score` questions. d1-3B answers several questions about one input in a shared pass; d3 runs them one after another.
|
|
68
|
+
- **Speech** (OmniVoice, VoxCPM2): `generate`, reusable voice prompts and on-device transcription. VoxCPM2 also streams. See the [speech API](docs/speech.md).
|
|
69
|
+
- **Text completion** (GPT-2): OpenAI-style `complete(prompt=..., max_tokens=...)` with streaming, sampling and batching.
|
|
70
|
+
|
|
71
|
+
`python -m tinkerbox_ane.storage` lists what each model keeps on disk. `--remove MODEL` deletes a model's files (with `--outdated`, only revisions the catalog no longer loads; `--outdated` alone does that for every model). `--remove-checkpoint REPO...` deletes upstream checkpoints, and `--remove-unused` deletes compiled copies that no bundle uses.
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
Building from source, exporting and publishing models, and running tests are covered in the [developer guide](docs/model-publishing.md). Releases follow [Releasing](docs/releasing.md).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<img width="1920" height="388" alt="banner" src="https://github.com/user-attachments/assets/52cfb1e7-c841-4898-9a94-d199db85f2d7" />
|
|
2
|
+
|
|
3
|
+
# Tinkerbox for Apple Neural Engine
|
|
4
|
+
|
|
5
|
+
Run models on Apple's Neural Engine through Core AI. Inference runs on the Neural Engine, the CPU handles tokenization and other light work, and the GPU stays idle.
|
|
6
|
+
|
|
7
|
+
| Model | Task | Chips | Notes |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| [LiquidAI/d1-3B](https://huggingface.co/LiquidAI/d1-3B) (`d1-3b`) | Decisions over text and images, several questions per pass | M4–M6 | [d1.md](docs/models/d1.md) |
|
|
10
|
+
| [vllm-sr/d3-nano](https://huggingface.co/vllm-sr/d3-nano), [d3-mini](https://huggingface.co/vllm-sr/d3-mini) (`d3-nano`, `d3-mini`) | Decisions over text and images | M4–M6 | [d3.md](docs/models/d3.md) |
|
|
11
|
+
| [k2-fsa/OmniVoice](https://huggingface.co/k2-fsa/OmniVoice) (`omnivoice`) | Speech, voice design and cloning | M4–M6 | [omnivoice.md](docs/models/omnivoice.md) |
|
|
12
|
+
| [openbmb/VoxCPM2](https://huggingface.co/openbmb/VoxCPM2) (`voxcpm2`, `voxcpm2-lut8`) | Speech, voice design, cloning and continuation | M1–M6 | [voxcpm2.md](docs/models/voxcpm2.md) |
|
|
13
|
+
| [openai-community/gpt2](https://huggingface.co/openai-community/gpt2) (`gpt2`, `gpt2-medium`, `gpt2-large`, `gpt2-xl`) | Text completion | M1–M6 | [gpt2.md](docs/models/gpt2.md) |
|
|
14
|
+
|
|
15
|
+
Requires macOS 27 on Apple Silicon.
|
|
16
|
+
|
|
17
|
+
## App
|
|
18
|
+
|
|
19
|
+
Download `Tinkerbox-ANE-*-macos-arm64.zip` from the [latest release](https://github.com/WeGoToMars/tinkerbox/releases/latest), move **Tinkerbox.app** to Applications and open it. It sets up its own Python environment and downloads each model the first time you select it. Its tasks are also available as Shortcuts actions. See the [app guide](app/README.md).
|
|
20
|
+
|
|
21
|
+
## Python
|
|
22
|
+
|
|
23
|
+
Python 3.12 or 3.13:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
python -m pip install tinkerbox-ane # add [speech] for OmniVoice and VoxCPM2
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import tinkerbox_ane
|
|
31
|
+
|
|
32
|
+
with tinkerbox_ane.load("d1-3b") as model:
|
|
33
|
+
result = model.system_one(
|
|
34
|
+
"I was charged twice this month.",
|
|
35
|
+
{"refund": {"type": "noul", "instructions": "Is this a refund request?"}},
|
|
36
|
+
)
|
|
37
|
+
print(result["answers"])
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`tinkerbox_ane.load(model_id)` downloads the Core AI bundle for this Mac to `~/Library/Caches/tinkerbox-ane/models/` and returns the API for the model's task. Pass a directory as the second argument to load a local bundle instead. Bundles include the tokenizer, configuration and the few weights that run on the CPU, so loading never downloads the upstream checkpoint.
|
|
41
|
+
|
|
42
|
+
- **Decisions** (d1, d3): `system_one`, `system_one_batch`, `probabilities`, `probabilities_batch` and `count_tokens` answer yes/no (`noul`), `choice` and `score` questions. d1-3B answers several questions about one input in a shared pass; d3 runs them one after another.
|
|
43
|
+
- **Speech** (OmniVoice, VoxCPM2): `generate`, reusable voice prompts and on-device transcription. VoxCPM2 also streams. See the [speech API](docs/speech.md).
|
|
44
|
+
- **Text completion** (GPT-2): OpenAI-style `complete(prompt=..., max_tokens=...)` with streaming, sampling and batching.
|
|
45
|
+
|
|
46
|
+
`python -m tinkerbox_ane.storage` lists what each model keeps on disk. `--remove MODEL` deletes a model's files (with `--outdated`, only revisions the catalog no longer loads; `--outdated` alone does that for every model). `--remove-checkpoint REPO...` deletes upstream checkpoints, and `--remove-unused` deletes compiled copies that no bundle uses.
|
|
47
|
+
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
Building from source, exporting and publishing models, and running tests are covered in the [developer guide](docs/model-publishing.md). Releases follow [Releasing](docs/releasing.md).
|
|
@@ -16,9 +16,11 @@ struct AudioWaveform: View {
|
|
|
16
16
|
let x = (Double(index) + 0.5) * size.width / Double(count)
|
|
17
17
|
let height = max(2, Double(peak) * (size.height - 12))
|
|
18
18
|
let bar = CGRect(x: x - 1, y: (size.height - height) / 2, width: 2, height: height)
|
|
19
|
-
context.fill(
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
context.fill(
|
|
20
|
+
Path(roundedRect: bar, cornerRadius: 1),
|
|
21
|
+
with: .color(
|
|
22
|
+
progress == nil || x <= size.width * (progress ?? 0)
|
|
23
|
+
? .accentColor : .secondary.opacity(0.45)))
|
|
22
24
|
}
|
|
23
25
|
if let progress {
|
|
24
26
|
let x = min(size.width - 1, max(1, size.width * progress))
|
|
@@ -48,10 +50,11 @@ struct AudioPlayback: View {
|
|
|
48
50
|
VStack(spacing: 12) {
|
|
49
51
|
GeometryReader { geometry in
|
|
50
52
|
AudioWaveform(peaks: peaks, progress: duration > 0 ? time / duration : 0)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
.contentShape(Rectangle())
|
|
54
|
+
.gesture(
|
|
55
|
+
DragGesture(minimumDistance: 0).onChanged { value in
|
|
56
|
+
seek(value.location.x / max(1, geometry.size.width) * duration)
|
|
57
|
+
})
|
|
55
58
|
}
|
|
56
59
|
.frame(height: 88)
|
|
57
60
|
.accessibilityElement(children: .ignore)
|
|
@@ -109,8 +112,7 @@ struct AudioPlayback: View {
|
|
|
109
112
|
player = try AVAudioPlayer(data: data)
|
|
110
113
|
player?.prepareToPlay()
|
|
111
114
|
peaks = samples
|
|
112
|
-
} catch is CancellationError { }
|
|
113
|
-
catch { self.error = error.localizedDescription }
|
|
115
|
+
} catch is CancellationError {} catch { self.error = error.localizedDescription }
|
|
114
116
|
}
|
|
115
117
|
.onDisappear {
|
|
116
118
|
position = player?.currentTime ?? 0
|
|
@@ -139,7 +141,9 @@ struct AudioPlayback: View {
|
|
|
139
141
|
try data.write(to: url)
|
|
140
142
|
let file = try AVAudioFile(forReading: url)
|
|
141
143
|
guard file.length > 0,
|
|
142
|
-
|
|
144
|
+
let buffer = AVAudioPCMBuffer(
|
|
145
|
+
pcmFormat: file.processingFormat, frameCapacity: AVAudioFrameCount(file.length))
|
|
146
|
+
else { return [] }
|
|
143
147
|
try file.read(into: buffer)
|
|
144
148
|
guard let channels = buffer.floatChannelData else { return [] }
|
|
145
149
|
let frames = Int(buffer.frameLength), count = min(1200, frames)
|
|
@@ -171,17 +175,18 @@ struct AudioPlayback: View {
|
|
|
171
175
|
var duration: Double { sampleRate > 0 ? Double(frames) / sampleRate : 0 }
|
|
172
176
|
var finished: Bool { stopped || (complete && unplayed == 0) }
|
|
173
177
|
var position: Double {
|
|
174
|
-
|
|
178
|
+
// The node joins the engine with the first piece; asking it the time before then raises.
|
|
179
|
+
guard sampleRate > 0, let now = node.lastRenderTime, let time = node.playerTime(forNodeTime: now) else {
|
|
180
|
+
return 0
|
|
181
|
+
}
|
|
175
182
|
return min(duration, max(0, Double(time.sampleTime) / sampleRate))
|
|
176
183
|
}
|
|
177
184
|
|
|
178
185
|
func append(_ chunk: SpeechChunk) {
|
|
179
|
-
guard !stopped else { return }
|
|
180
186
|
let count = chunk.pcm.count / 2
|
|
187
|
+
guard !stopped, count > 0 else { return }
|
|
181
188
|
if sampleRate == 0 {
|
|
182
|
-
|
|
183
|
-
return fail("Unsupported speech sample rate.")
|
|
184
|
-
}
|
|
189
|
+
let format = AVAudioFormat(standardFormatWithSampleRate: Double(chunk.sampleRate), channels: 1)!
|
|
185
190
|
sampleRate = format.sampleRate
|
|
186
191
|
engine.attach(node)
|
|
187
192
|
do {
|
|
@@ -190,13 +195,13 @@ struct AudioPlayback: View {
|
|
|
190
195
|
try node.playAudio()
|
|
191
196
|
} catch { return fail(error.localizedDescription) }
|
|
192
197
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
let samples = buffer.floatChannelData?[0] else { return fail("The model returned unplayable audio.") }
|
|
198
|
+
let buffer = AVAudioPCMBuffer(pcmFormat: node.outputFormat(forBus: 0), frameCapacity: AVAudioFrameCount(count))!
|
|
199
|
+
let samples = buffer.floatChannelData![0]
|
|
196
200
|
buffer.frameLength = AVAudioFrameCount(count)
|
|
197
201
|
chunk.pcm.withUnsafeBytes { raw in
|
|
198
202
|
for index in 0..<count {
|
|
199
|
-
samples[index] =
|
|
203
|
+
samples[index] =
|
|
204
|
+
Float(Int16(littleEndian: raw.loadUnaligned(fromByteOffset: 2 * index, as: Int16.self))) / 32768
|
|
200
205
|
}
|
|
201
206
|
}
|
|
202
207
|
// One peak per 10 ms, matching the finished clip's waveform closely enough while it grows.
|
|
@@ -251,13 +256,17 @@ struct StreamingPlayback: View {
|
|
|
251
256
|
HStack {
|
|
252
257
|
Text(playbackStamp(time))
|
|
253
258
|
Spacer()
|
|
254
|
-
Text(
|
|
255
|
-
|
|
259
|
+
Text(
|
|
260
|
+
audio.complete
|
|
261
|
+
? "−" + playbackStamp(audio.duration - time)
|
|
262
|
+
: "Generating · \(playbackStamp(audio.duration)) ready")
|
|
256
263
|
}
|
|
257
264
|
.font(.caption.monospacedDigit()).foregroundStyle(.secondary)
|
|
258
265
|
HStack(spacing: 32) {
|
|
259
|
-
Button(audio.paused ? "Play" : "Pause", systemImage: audio.paused ? "play.fill" : "pause.fill") {
|
|
260
|
-
.
|
|
266
|
+
Button(audio.paused ? "Play" : "Pause", systemImage: audio.paused ? "play.fill" : "pause.fill") {
|
|
267
|
+
audio.toggle()
|
|
268
|
+
}
|
|
269
|
+
.font(.system(size: 30)).frame(width: 44, height: 44)
|
|
261
270
|
Button("Stop", systemImage: "stop.fill") { audio.stop() }
|
|
262
271
|
}
|
|
263
272
|
.font(.title2).labelStyle(.iconOnly).buttonStyle(.plain)
|
|
@@ -25,7 +25,8 @@ import SwiftUI
|
|
|
25
25
|
preparing = false
|
|
26
26
|
armed = allowed
|
|
27
27
|
if !allowed {
|
|
28
|
-
error =
|
|
28
|
+
error =
|
|
29
|
+
"Allow microphone access in System Settings → Privacy & Security → Microphone to record a sample."
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -45,14 +46,17 @@ import SwiftUI
|
|
|
45
46
|
try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
|
|
46
47
|
take += 1
|
|
47
48
|
let url = folder.appending(path: "Voice sample \(take).wav")
|
|
48
|
-
let recorder = try AVAudioRecorder(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
let recorder = try AVAudioRecorder(
|
|
50
|
+
url: url,
|
|
51
|
+
settings: [
|
|
52
|
+
AVFormatIDKey: kAudioFormatLinearPCM, AVSampleRateKey: 24_000,
|
|
53
|
+
AVNumberOfChannelsKey: 1, AVLinearPCMBitDepthKey: 16,
|
|
54
|
+
AVLinearPCMIsFloatKey: false, AVLinearPCMIsBigEndianKey: false,
|
|
55
|
+
])
|
|
53
56
|
recorder.isMeteringEnabled = true
|
|
54
57
|
guard recorder.record(forDuration: 20) else {
|
|
55
|
-
|
|
58
|
+
error = "Could not start recording from the microphone."
|
|
59
|
+
return
|
|
56
60
|
}
|
|
57
61
|
self.recorder = recorder
|
|
58
62
|
self.completion = completion
|