fixed a bug

This commit is contained in:
2026-08-26 10:46:09 +08:00
parent 1b6090e44c
commit a6297e2f9f
4 changed files with 102 additions and 2 deletions

View File

@@ -86,12 +86,28 @@ class VideoRepository:
text TEXT,
audio_filename TEXT NOT NULL,
audio_size_bytes INTEGER NOT NULL,
overall_score REAL NOT NULL DEFAULT 0,
recognized_text TEXT NOT NULL DEFAULT '',
FOREIGN KEY (share_id) REFERENCES dub_shares(share_id) ON DELETE CASCADE,
UNIQUE (share_id, sentence_index)
);
"""
)
with self._connect() as connection:
columns = {
row["name"]
for row in connection.execute("PRAGMA table_info(dub_share_segments)")
}
if "overall_score" not in columns:
connection.execute(
"ALTER TABLE dub_share_segments ADD COLUMN overall_score REAL NOT NULL DEFAULT 0"
)
if "recognized_text" not in columns:
connection.execute(
"ALTER TABLE dub_share_segments ADD COLUMN recognized_text TEXT NOT NULL DEFAULT ''"
)
def upsert_upload(
self,
*,
@@ -312,8 +328,8 @@ class VideoRepository:
"""
INSERT INTO dub_share_segments (
share_id, sentence_index, start_ms, end_ms, text,
audio_filename, audio_size_bytes
) VALUES (?, ?, ?, ?, ?, ?, ?)
audio_filename, audio_size_bytes, overall_score, recognized_text
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
[
(
@@ -324,6 +340,8 @@ class VideoRepository:
segment["text"],
segment["audio_filename"],
segment["audio_size_bytes"],
segment.get("overall_score", 0),
segment.get("recognized_text", ""),
)
for segment in segments
],