@clipen/clipen-cli 1.0.0 → 1.0.1
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.
- package/README.md +60 -50
- package/package.json +7 -4
- package/pyproject.toml +18 -2
- package/requirements/dev.txt +2 -0
- package/src/clipen/__init__.py +1 -1
- package/src/clipen/analysis/__init__.py +7 -7
- package/src/clipen/analysis/artifacts.py +4 -10
- package/src/clipen/analysis/audio.py +10 -8
- package/src/clipen/analysis/evidence_service.py +345 -167
- package/src/clipen/analysis/image_similarity.py +5 -14
- package/src/clipen/analysis/keyframes.py +5 -17
- package/src/clipen/analysis/models.py +5 -7
- package/src/clipen/analysis/qwen_worker.py +19 -54
- package/src/clipen/analysis/resources.py +2 -1
- package/src/clipen/analysis/runtime.py +1 -3
- package/src/clipen/analysis/service.py +16 -48
- package/src/clipen/analysis/setup.py +11 -25
- package/src/clipen/analysis/setup_cli.py +5 -15
- package/src/clipen/analysis/storage.py +96 -278
- package/src/clipen/analysis/transcription.py +40 -82
- package/src/clipen/analysis/visual.py +109 -48
- package/src/clipen/annotations/__init__.py +5 -2
- package/src/clipen/annotations/models.py +1 -1
- package/src/clipen/annotations/storage.py +132 -84
- package/src/clipen/annotations/suggestions.py +3 -8
- package/src/clipen/asr_release.py +4 -11
- package/src/clipen/bootstrap.py +65 -54
- package/src/clipen/{planning/models.py → candidates.py} +29 -47
- package/src/clipen/cli.py +2 -2
- package/src/clipen/controller/app.py +401 -214
- package/src/clipen/controller/server.py +28 -38
- package/src/clipen/domain/__init__.py +1 -1
- package/src/clipen/domain/media_time.py +3 -10
- package/src/clipen/domain/timeline.py +45 -47
- package/src/clipen/domain/validation.py +0 -1
- package/src/clipen/editing/__init__.py +1 -1
- package/src/clipen/editing/agent_models.py +4 -11
- package/src/clipen/editing/agent_repository.py +391 -170
- package/src/clipen/editing/agent_tools.py +180 -99
- package/src/clipen/editing/alignment.py +92 -52
- package/src/clipen/editing/alignment_setup.py +118 -70
- package/src/clipen/editing/alignment_worker.py +11 -9
- package/src/clipen/editing/change_report.py +95 -38
- package/src/clipen/editing/compiler.py +0 -1
- package/src/clipen/editing/component_looks.py +58 -34
- package/src/clipen/editing/component_review.py +34 -38
- package/src/clipen/editing/coordinator.py +213 -90
- package/src/clipen/editing/editorial_review.py +217 -95
- package/src/clipen/editing/evidence_jobs.py +457 -200
- package/src/clipen/editing/history_changes.py +129 -68
- package/src/clipen/editing/music_choices.py +8 -5
- package/src/clipen/editing/production_catalog.py +573 -136
- package/src/clipen/editing/production_limits.py +43 -17
- package/src/clipen/editing/production_media.py +376 -167
- package/src/clipen/editing/production_preview.py +322 -129
- package/src/clipen/editing/production_progress.py +164 -69
- package/src/clipen/editing/production_requirements.py +106 -39
- package/src/clipen/editing/production_tools.py +1064 -462
- package/src/clipen/editing/program_audio.py +211 -81
- package/src/clipen/editing/program_direction.py +59 -25
- package/src/clipen/editing/program_story.py +83 -45
- package/src/clipen/editing/program_subtitles.py +194 -96
- package/src/clipen/editing/programme_review.py +98 -50
- package/src/clipen/editing/prompt_history.py +64 -27
- package/src/clipen/editing/recut.py +65 -25
- package/src/clipen/editing/refinement_references.py +176 -86
- package/src/clipen/editing/resolve_export.py +449 -218
- package/src/clipen/editing/resolve_titles.py +162 -105
- package/src/clipen/editing/skill_tools.py +530 -154
- package/src/clipen/editing/source_dialogue.py +177 -67
- package/src/clipen/editing/speech_coverage.py +42 -22
- package/src/clipen/editing/speech_quality.py +6 -1
- package/src/clipen/editing/tool_receipts.py +78 -32
- package/src/clipen/editing/versions.py +122 -64
- package/src/clipen/editing/visual_preview.py +157 -61
- package/src/clipen/editing/workbench.py +104 -42
- package/src/clipen/finishing/audio.py +69 -30
- package/src/clipen/finishing/catalog.py +176 -93
- package/src/clipen/finishing/models.py +1 -1
- package/src/clipen/finishing/renderer.py +33 -14
- package/src/clipen/mcp_editing/__main__.py +3 -1
- package/src/clipen/mcp_editing/server.py +77 -34
- package/src/clipen/media/__init__.py +3 -3
- package/src/clipen/media/discovery.py +7 -20
- package/src/clipen/media/models.py +7 -18
- package/src/clipen/media/preview.py +14 -24
- package/src/clipen/media/probe.py +16 -44
- package/src/clipen/media/service.py +6 -19
- package/src/clipen/media/storage.py +33 -81
- package/src/clipen/music_vocabulary.py +33 -4
- package/src/clipen/power.py +8 -3
- package/src/clipen/projects/__init__.py +1 -1
- package/src/clipen/projects/deletion.py +19 -32
- package/src/clipen/projects/finishing_schema.py +3 -1
- package/src/clipen/projects/models.py +2 -5
- package/src/clipen/projects/picker.py +13 -37
- package/src/clipen/projects/service.py +8 -24
- package/src/clipen/projects/storage.py +226 -246
- package/src/clipen/provider_registry.py +4 -2
- package/src/clipen/providers/account.py +86 -35
- package/src/clipen/providers/claude.py +59 -25
- package/src/clipen/providers/claude_editing.py +14 -7
- package/src/clipen/providers/codex.py +73 -118
- package/src/clipen/providers/codex_editing.py +2 -2
- package/src/clipen/providers/editing_agent.py +19 -17
- package/src/clipen/providers/recovery.py +7 -8
- package/src/clipen/rendering/cover.py +18 -5
- package/src/clipen/rendering/custom_components.py +167 -79
- package/src/clipen/rendering/custom_render.py +62 -41
- package/src/clipen/rendering/production_effects.py +77 -45
- package/src/clipen/rendering/program_components.py +134 -73
- package/src/clipen/rendering/program_creator.py +432 -277
- package/src/clipen/rendering/program_identities.py +277 -182
- package/src/clipen/rendering/program_motion.py +140 -95
- package/src/clipen/rendering/program_studio.py +175 -116
- package/src/clipen/rendering/program_styles.py +231 -145
- package/src/clipen/rendering/program_subtitles.py +71 -34
- package/src/clipen/rendering/renderer.py +150 -121
- package/src/clipen/rendering/storage.py +9 -22
- package/src/clipen/rendering/titles.py +193 -86
- package/src/clipen/skills/__init__.py +1 -0
- package/src/clipen/skills/catalog.py +151 -55
- package/src/clipen/skills/library.py +13 -7
- package/src/clipen/skills/package.py +46 -23
- package/src/clipen/skills/visual_styles.py +29 -18
- package/src/clipen/workspace.py +15 -44
- package/src/clipen/planning/__init__.py +0 -9
|
@@ -13,7 +13,6 @@ from clipen.projects.storage import ProjectRepository, command_digest, utc_now
|
|
|
13
13
|
from .models import DayPart, MaterialUsage
|
|
14
14
|
from .suggestions import annotation_suggestion
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
_VERSION_ID = re.compile(r"av_[0-9a-f]{32}\Z")
|
|
18
17
|
|
|
19
18
|
|
|
@@ -31,28 +30,23 @@ class AnnotationRepository:
|
|
|
31
30
|
"SELECT * FROM material_annotations WHERE version_id=?",
|
|
32
31
|
(version_id,),
|
|
33
32
|
).fetchone()
|
|
34
|
-
transcript =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
transcript = (
|
|
34
|
+
database.execute(
|
|
35
|
+
"SELECT * FROM transcript_annotations WHERE version_id=? AND stream_index=?",
|
|
36
|
+
(version_id, stream_index),
|
|
37
|
+
).fetchone()
|
|
38
|
+
if stream_index >= 0
|
|
39
|
+
else None
|
|
41
40
|
)
|
|
41
|
+
current_revision = self._current_transcript_revision(database, version_id, stream_index)
|
|
42
42
|
suggestion = annotation_suggestion(database, version_id)
|
|
43
|
-
return self._public(
|
|
44
|
-
material, transcript, version_id, stream_index, current_revision, suggestion
|
|
45
|
-
)
|
|
43
|
+
return self._public(material, transcript, version_id, stream_index, current_revision, suggestion)
|
|
46
44
|
except ProjectError:
|
|
47
45
|
raise
|
|
48
46
|
except (json.JSONDecodeError, TypeError, ValueError) as error:
|
|
49
|
-
raise ProjectError(
|
|
50
|
-
"storage_corrupt", "Clipen 無法讀取素材標註。", status_code=500
|
|
51
|
-
) from error
|
|
47
|
+
raise ProjectError("storage_corrupt", "Clipen 無法讀取素材標註。", status_code=500) from error
|
|
52
48
|
except sqlite3.Error as error:
|
|
53
|
-
raise ProjectError(
|
|
54
|
-
"storage_failed", "Clipen 無法讀取素材標註。", status_code=500
|
|
55
|
-
) from error
|
|
49
|
+
raise ProjectError("storage_failed", "Clipen 無法讀取素材標註。", status_code=500) from error
|
|
56
50
|
|
|
57
51
|
def save(
|
|
58
52
|
self,
|
|
@@ -72,14 +66,16 @@ class AnnotationRepository:
|
|
|
72
66
|
transcript_revision = self._expected_revision(expected_transcript_revision)
|
|
73
67
|
normalized_material = self._material(material)
|
|
74
68
|
normalized_transcript = self._transcript(transcript, stream_index)
|
|
75
|
-
request_hash = command_digest(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
request_hash = command_digest(
|
|
70
|
+
{
|
|
71
|
+
"version_id": version_id,
|
|
72
|
+
"stream_index": stream_index,
|
|
73
|
+
"expected_material_revision": material_revision,
|
|
74
|
+
"expected_transcript_revision": transcript_revision,
|
|
75
|
+
"material": normalized_material,
|
|
76
|
+
"transcript": normalized_transcript,
|
|
77
|
+
}
|
|
78
|
+
)
|
|
83
79
|
now = utc_now()
|
|
84
80
|
try:
|
|
85
81
|
with self.projects.connect(project_id) as database:
|
|
@@ -105,11 +101,14 @@ class AnnotationRepository:
|
|
|
105
101
|
(version_id,),
|
|
106
102
|
).fetchone()
|
|
107
103
|
observed_material = 0 if current_material is None else current_material["revision"]
|
|
108
|
-
current_transcript =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
current_transcript = (
|
|
105
|
+
database.execute(
|
|
106
|
+
"SELECT revision FROM transcript_annotations WHERE version_id=? AND stream_index=?",
|
|
107
|
+
(version_id, stream_index),
|
|
108
|
+
).fetchone()
|
|
109
|
+
if stream_index >= 0
|
|
110
|
+
else None
|
|
111
|
+
)
|
|
113
112
|
observed_transcript = 0 if current_transcript is None else current_transcript["revision"]
|
|
114
113
|
if observed_material != material_revision or observed_transcript != transcript_revision:
|
|
115
114
|
raise ProjectError(
|
|
@@ -127,27 +126,27 @@ class AnnotationRepository:
|
|
|
127
126
|
"day_part=excluded.day_part,note=excluded.note,usage=excluded.usage,"
|
|
128
127
|
"updated_at=excluded.updated_at",
|
|
129
128
|
(
|
|
130
|
-
version_id,
|
|
129
|
+
version_id,
|
|
130
|
+
next_material,
|
|
131
131
|
json.dumps(normalized_material["people"], ensure_ascii=False, separators=(",", ":")),
|
|
132
|
-
normalized_material["location"],
|
|
133
|
-
normalized_material["
|
|
134
|
-
normalized_material["
|
|
132
|
+
normalized_material["location"],
|
|
133
|
+
normalized_material["trip_day"],
|
|
134
|
+
normalized_material["day_part"],
|
|
135
|
+
normalized_material["note"],
|
|
136
|
+
normalized_material["usage"],
|
|
137
|
+
now,
|
|
135
138
|
),
|
|
136
139
|
)
|
|
137
140
|
next_transcript = observed_transcript
|
|
138
141
|
if normalized_transcript is not None:
|
|
139
|
-
source_revision = self._current_transcript_revision(
|
|
140
|
-
database, version_id, stream_index
|
|
141
|
-
)
|
|
142
|
+
source_revision = self._current_transcript_revision(database, version_id, stream_index)
|
|
142
143
|
if source_revision is None or source_revision != normalized_transcript["source_revision_id"]:
|
|
143
144
|
raise ProjectError(
|
|
144
145
|
"annotation_transcript_changed",
|
|
145
146
|
"逐字稿已重新分析,請重新載入後再保存修正。",
|
|
146
147
|
status_code=409,
|
|
147
148
|
)
|
|
148
|
-
self._validate_corrections(
|
|
149
|
-
database, source_revision, normalized_transcript["corrections"]
|
|
150
|
-
)
|
|
149
|
+
self._validate_corrections(database, source_revision, normalized_transcript["corrections"])
|
|
151
150
|
next_transcript += 1
|
|
152
151
|
database.execute(
|
|
153
152
|
"INSERT INTO transcript_annotations "
|
|
@@ -159,7 +158,10 @@ class AnnotationRepository:
|
|
|
159
158
|
"corrections_json=excluded.corrections_json,"
|
|
160
159
|
"updated_at=excluded.updated_at",
|
|
161
160
|
(
|
|
162
|
-
version_id,
|
|
161
|
+
version_id,
|
|
162
|
+
stream_index,
|
|
163
|
+
source_revision,
|
|
164
|
+
next_transcript,
|
|
163
165
|
int(normalized_transcript["confirmed"]),
|
|
164
166
|
int(normalized_transcript["discarded"]),
|
|
165
167
|
json.dumps(normalized_transcript["corrections"], ensure_ascii=False, separators=(",", ":")),
|
|
@@ -169,12 +171,19 @@ class AnnotationRepository:
|
|
|
169
171
|
material_row = database.execute(
|
|
170
172
|
"SELECT * FROM material_annotations WHERE version_id=?", (version_id,)
|
|
171
173
|
).fetchone()
|
|
172
|
-
transcript_row =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
transcript_row = (
|
|
175
|
+
database.execute(
|
|
176
|
+
"SELECT * FROM transcript_annotations WHERE version_id=? AND stream_index=?",
|
|
177
|
+
(version_id, stream_index),
|
|
178
|
+
).fetchone()
|
|
179
|
+
if stream_index >= 0
|
|
180
|
+
else None
|
|
181
|
+
)
|
|
176
182
|
response = self._public(
|
|
177
|
-
material_row,
|
|
183
|
+
material_row,
|
|
184
|
+
transcript_row,
|
|
185
|
+
version_id,
|
|
186
|
+
stream_index,
|
|
178
187
|
self._current_transcript_revision(database, version_id, stream_index),
|
|
179
188
|
annotation_suggestion(database, version_id),
|
|
180
189
|
)
|
|
@@ -183,7 +192,8 @@ class AnnotationRepository:
|
|
|
183
192
|
"(request_id,command_type,request_hash,response_json,created_at) "
|
|
184
193
|
"VALUES(?,'save_annotation',?,?,?)",
|
|
185
194
|
(
|
|
186
|
-
normalized_request,
|
|
195
|
+
normalized_request,
|
|
196
|
+
request_hash,
|
|
187
197
|
json.dumps(response, ensure_ascii=False, sort_keys=True, separators=(",", ":")),
|
|
188
198
|
now,
|
|
189
199
|
),
|
|
@@ -193,13 +203,9 @@ class AnnotationRepository:
|
|
|
193
203
|
except ProjectError:
|
|
194
204
|
raise
|
|
195
205
|
except (json.JSONDecodeError, TypeError, ValueError) as error:
|
|
196
|
-
raise ProjectError(
|
|
197
|
-
"annotation_invalid", "素材標註內容無效。", status_code=422
|
|
198
|
-
) from error
|
|
206
|
+
raise ProjectError("annotation_invalid", "素材標註內容無效。", status_code=422) from error
|
|
199
207
|
except sqlite3.Error as error:
|
|
200
|
-
raise ProjectError(
|
|
201
|
-
"storage_failed", "Clipen 無法保存素材標註。", status_code=500
|
|
202
|
-
) from error
|
|
208
|
+
raise ProjectError("storage_failed", "Clipen 無法保存素材標註。", status_code=500) from error
|
|
203
209
|
|
|
204
210
|
@staticmethod
|
|
205
211
|
def _validate_identity(version_id: str, stream_index: int) -> None:
|
|
@@ -216,7 +222,14 @@ class AnnotationRepository:
|
|
|
216
222
|
|
|
217
223
|
@staticmethod
|
|
218
224
|
def _material(value: object) -> dict[str, object]:
|
|
219
|
-
if not isinstance(value, Mapping) or set(value) != {
|
|
225
|
+
if not isinstance(value, Mapping) or set(value) != {
|
|
226
|
+
"people",
|
|
227
|
+
"location",
|
|
228
|
+
"trip_day",
|
|
229
|
+
"day_part",
|
|
230
|
+
"note",
|
|
231
|
+
"usage",
|
|
232
|
+
}:
|
|
220
233
|
raise ProjectError("annotation_invalid", "素材標註內容無效。", status_code=422)
|
|
221
234
|
people = value["people"]
|
|
222
235
|
if not isinstance(people, list) or len(people) > 20:
|
|
@@ -230,12 +243,16 @@ class AnnotationRepository:
|
|
|
230
243
|
raise ProjectError("annotation_invalid", "人物標註不能重複。", status_code=422)
|
|
231
244
|
location = value["location"]
|
|
232
245
|
note = value["note"]
|
|
233
|
-
if location is not None and (
|
|
246
|
+
if location is not None and (
|
|
247
|
+
not isinstance(location, str) or "\x00" in location or len(location.strip()) > 160
|
|
248
|
+
):
|
|
234
249
|
raise ProjectError("annotation_invalid", "地點標註內容無效。", status_code=422)
|
|
235
250
|
if not isinstance(note, str) or "\x00" in note or len(note) > 2_000:
|
|
236
251
|
raise ProjectError("annotation_invalid", "剪輯備註內容無效。", status_code=422)
|
|
237
252
|
trip_day = value["trip_day"]
|
|
238
|
-
if trip_day is not None and (
|
|
253
|
+
if trip_day is not None and (
|
|
254
|
+
isinstance(trip_day, bool) or not isinstance(trip_day, int) or not 1 <= trip_day <= 365
|
|
255
|
+
):
|
|
239
256
|
raise ProjectError("annotation_invalid", "旅程日次無效。", status_code=422)
|
|
240
257
|
day_part = value["day_part"]
|
|
241
258
|
usage = value["usage"]
|
|
@@ -244,9 +261,7 @@ class AnnotationRepository:
|
|
|
244
261
|
day_part = DayPart(day_part).value
|
|
245
262
|
usage = MaterialUsage(usage).value
|
|
246
263
|
except (TypeError, ValueError) as error:
|
|
247
|
-
raise ProjectError(
|
|
248
|
-
"annotation_invalid", "素材使用方式或旅程時段無效。", status_code=422
|
|
249
|
-
) from error
|
|
264
|
+
raise ProjectError("annotation_invalid", "素材使用方式或旅程時段無效。", status_code=422) from error
|
|
250
265
|
return {
|
|
251
266
|
"people": normalized_people,
|
|
252
267
|
"location": None if location is None or not location.strip() else location.strip(),
|
|
@@ -260,13 +275,24 @@ class AnnotationRepository:
|
|
|
260
275
|
def _transcript(value: object, stream_index: int) -> dict[str, object] | None:
|
|
261
276
|
if value is None:
|
|
262
277
|
return None
|
|
263
|
-
if
|
|
278
|
+
if (
|
|
279
|
+
stream_index < 0
|
|
280
|
+
or not isinstance(value, Mapping)
|
|
281
|
+
or set(value) != {"source_revision_id", "confirmed", "discarded", "corrections"}
|
|
282
|
+
):
|
|
264
283
|
raise ProjectError("annotation_invalid", "逐字稿修正內容無效。", status_code=422)
|
|
265
284
|
source_revision = value["source_revision_id"]
|
|
266
285
|
confirmed = value["confirmed"]
|
|
267
286
|
discarded = value["discarded"]
|
|
268
287
|
corrections = value["corrections"]
|
|
269
|
-
if
|
|
288
|
+
if (
|
|
289
|
+
not isinstance(source_revision, str)
|
|
290
|
+
or not source_revision
|
|
291
|
+
or not isinstance(confirmed, bool)
|
|
292
|
+
or not isinstance(discarded, bool)
|
|
293
|
+
or not isinstance(corrections, list)
|
|
294
|
+
or len(corrections) > 1_000
|
|
295
|
+
):
|
|
270
296
|
raise ProjectError("annotation_invalid", "逐字稿修正內容無效。", status_code=422)
|
|
271
297
|
normalized = []
|
|
272
298
|
ordinals = set()
|
|
@@ -275,7 +301,15 @@ class AnnotationRepository:
|
|
|
275
301
|
raise ProjectError("annotation_invalid", "逐字稿修正內容無效。", status_code=422)
|
|
276
302
|
ordinal = correction["ordinal"]
|
|
277
303
|
text = correction["text"]
|
|
278
|
-
if
|
|
304
|
+
if (
|
|
305
|
+
isinstance(ordinal, bool)
|
|
306
|
+
or not isinstance(ordinal, int)
|
|
307
|
+
or ordinal < 0
|
|
308
|
+
or ordinal in ordinals
|
|
309
|
+
or not isinstance(text, str)
|
|
310
|
+
or "\x00" in text
|
|
311
|
+
or len(text) > 1_000
|
|
312
|
+
):
|
|
279
313
|
raise ProjectError("annotation_invalid", "逐字稿修正內容無效。", status_code=422)
|
|
280
314
|
ordinals.add(ordinal)
|
|
281
315
|
normalized.append({"ordinal": ordinal, "text": text.strip()})
|
|
@@ -308,14 +342,11 @@ class AnnotationRepository:
|
|
|
308
342
|
def _validate_corrections(database: sqlite3.Connection, revision_id: str, corrections: object) -> None:
|
|
309
343
|
available = {
|
|
310
344
|
row["ordinal"]
|
|
311
|
-
for row in database.execute(
|
|
312
|
-
"SELECT ordinal FROM transcript_segments WHERE revision_id=?", (revision_id,)
|
|
313
|
-
)
|
|
345
|
+
for row in database.execute("SELECT ordinal FROM transcript_segments WHERE revision_id=?", (revision_id,))
|
|
314
346
|
}
|
|
315
347
|
if any(item["ordinal"] not in available for item in corrections):
|
|
316
348
|
raise ProjectError("annotation_transcript_changed", "逐字稿片段已更新,請重新載入。", status_code=409)
|
|
317
349
|
|
|
318
|
-
|
|
319
350
|
@staticmethod
|
|
320
351
|
def _public(
|
|
321
352
|
material,
|
|
@@ -327,26 +358,40 @@ class AnnotationRepository:
|
|
|
327
358
|
) -> dict[str, object]:
|
|
328
359
|
if material is None:
|
|
329
360
|
material_public = {
|
|
330
|
-
"version_id": version_id,
|
|
331
|
-
"
|
|
361
|
+
"version_id": version_id,
|
|
362
|
+
"revision": 0,
|
|
363
|
+
"people": [],
|
|
364
|
+
"location": None,
|
|
365
|
+
"trip_day": None,
|
|
366
|
+
"day_part": None,
|
|
367
|
+
"note": "",
|
|
368
|
+
"usage": "normal",
|
|
332
369
|
}
|
|
333
370
|
else:
|
|
334
371
|
people = json.loads(material["people_json"])
|
|
335
372
|
try:
|
|
336
|
-
normalized = AnnotationRepository._material(
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
373
|
+
normalized = AnnotationRepository._material(
|
|
374
|
+
{
|
|
375
|
+
"people": people,
|
|
376
|
+
"location": material["location"],
|
|
377
|
+
"trip_day": material["trip_day"],
|
|
378
|
+
"day_part": material["day_part"],
|
|
379
|
+
"note": material["note"],
|
|
380
|
+
"usage": material["usage"],
|
|
381
|
+
}
|
|
382
|
+
)
|
|
344
383
|
except ProjectError as error:
|
|
345
384
|
raise ValueError("stored material annotation is invalid") from error
|
|
346
|
-
if
|
|
385
|
+
if (
|
|
386
|
+
isinstance(material["revision"], bool)
|
|
387
|
+
or not isinstance(material["revision"], int)
|
|
388
|
+
or material["revision"] < 1
|
|
389
|
+
):
|
|
347
390
|
raise ValueError("stored material annotation revision is invalid")
|
|
348
391
|
material_public = {
|
|
349
|
-
"version_id": version_id,
|
|
392
|
+
"version_id": version_id,
|
|
393
|
+
"revision": material["revision"],
|
|
394
|
+
**normalized,
|
|
350
395
|
}
|
|
351
396
|
transcript_public = None
|
|
352
397
|
if current_revision is not None:
|
|
@@ -354,12 +399,15 @@ class AnnotationRepository:
|
|
|
354
399
|
corrections = [] if transcript is None or stale else json.loads(transcript["corrections_json"])
|
|
355
400
|
if transcript is not None and not stale:
|
|
356
401
|
try:
|
|
357
|
-
normalized_transcript = AnnotationRepository._transcript(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
402
|
+
normalized_transcript = AnnotationRepository._transcript(
|
|
403
|
+
{
|
|
404
|
+
"source_revision_id": current_revision,
|
|
405
|
+
"confirmed": bool(transcript["confirmed"]),
|
|
406
|
+
"discarded": bool(transcript["discarded"]),
|
|
407
|
+
"corrections": corrections,
|
|
408
|
+
},
|
|
409
|
+
stream_index,
|
|
410
|
+
)
|
|
363
411
|
except ProjectError as error:
|
|
364
412
|
raise ValueError("stored transcript annotation is invalid") from error
|
|
365
413
|
assert normalized_transcript is not None
|
|
@@ -2,18 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from datetime import datetime
|
|
6
5
|
import json
|
|
7
6
|
import re
|
|
8
7
|
import sqlite3
|
|
9
|
-
|
|
8
|
+
from datetime import datetime
|
|
10
9
|
|
|
11
10
|
_FILENAME_TIME = re.compile(r"(?<!\d)(20\d{12})(?!\d)")
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
def annotation_suggestion(
|
|
15
|
-
database: sqlite3.Connection, version_id: str
|
|
16
|
-
) -> dict[str, object]:
|
|
13
|
+
def annotation_suggestion(database: sqlite3.Connection, version_id: str) -> dict[str, object]:
|
|
17
14
|
return annotation_suggestions(database).get(version_id, _empty())
|
|
18
15
|
|
|
19
16
|
|
|
@@ -44,9 +41,7 @@ def annotation_suggestions(
|
|
|
44
41
|
|
|
45
42
|
day_numbers = {
|
|
46
43
|
capture_date: index
|
|
47
|
-
for index, capture_date in enumerate(
|
|
48
|
-
sorted({value.date() for value in captures.values()}), start=1
|
|
49
|
-
)
|
|
44
|
+
for index, capture_date in enumerate(sorted({value.date() for value in captures.values()}), start=1)
|
|
50
45
|
}
|
|
51
46
|
result: dict[str, dict[str, object]] = {}
|
|
52
47
|
for row in rows:
|
|
@@ -5,9 +5,8 @@ from __future__ import annotations
|
|
|
5
5
|
import hashlib
|
|
6
6
|
import json
|
|
7
7
|
import os
|
|
8
|
-
from pathlib import Path
|
|
9
8
|
import stat
|
|
10
|
-
|
|
9
|
+
from pathlib import Path
|
|
11
10
|
|
|
12
11
|
NOTICE_VERSION = "asr-qwen3-1.7b-confidence-v1"
|
|
13
12
|
RELEASE_ID = "qwen3-asr-1.7b-confidence-v1"
|
|
@@ -46,8 +45,7 @@ ASR_SOFTWARE_LICENSE_URL = "https://github.com/appautomaton/mlx-speech/blob/main
|
|
|
46
45
|
MODEL_LICENSE = "Apache-2.0"
|
|
47
46
|
MODEL_LICENSE_URL = f"https://huggingface.co/{MODEL_REPOSITORY}"
|
|
48
47
|
LICENSE_NOTICE = (
|
|
49
|
-
"Qwen3-ASR 模型採 Apache-2.0,MLX Speech 執行程式採 MIT;"
|
|
50
|
-
"Clipen 只下載固定版本,不會把模型檔收進 Repo。"
|
|
48
|
+
"Qwen3-ASR 模型採 Apache-2.0,MLX Speech 執行程式採 MIT;Clipen 只下載固定版本,不會把模型檔收進 Repo。"
|
|
51
49
|
)
|
|
52
50
|
PROGRESS_RECORD_PREFIX = "CLIPEN_PROGRESS\t"
|
|
53
51
|
|
|
@@ -85,9 +83,7 @@ def quick_release_is_ready(data_root: Path, requirements: Path) -> bool:
|
|
|
85
83
|
"runtime_python": "runtime/bin/python",
|
|
86
84
|
"model_path": "model",
|
|
87
85
|
}
|
|
88
|
-
if not isinstance(receipt, dict) or any(
|
|
89
|
-
receipt.get(key) != value for key, value in required.items()
|
|
90
|
-
):
|
|
86
|
+
if not isinstance(receipt, dict) or any(receipt.get(key) != value for key, value in required.items()):
|
|
91
87
|
return False
|
|
92
88
|
if set(receipt) != {*required, "model_manifest_sha256"}:
|
|
93
89
|
return False
|
|
@@ -97,10 +93,7 @@ def quick_release_is_ready(data_root: Path, requirements: Path) -> bool:
|
|
|
97
93
|
runtime_root = release / "runtime"
|
|
98
94
|
runtime_bin = runtime_root / "bin"
|
|
99
95
|
model_root = release / "model"
|
|
100
|
-
if any(
|
|
101
|
-
path.is_symlink() or not path.is_dir()
|
|
102
|
-
for path in (runtime_root, runtime_bin, model_root)
|
|
103
|
-
):
|
|
96
|
+
if any(path.is_symlink() or not path.is_dir() for path in (runtime_root, runtime_bin, model_root)):
|
|
104
97
|
return False
|
|
105
98
|
python = runtime_bin / "python"
|
|
106
99
|
if python.is_symlink() or not python.is_file() or not os.access(python, os.X_OK):
|