feat: add audio clip annotation view for dialect rating

This commit is contained in:
smaubio
2026-03-13 14:49:46 +01:00
parent 2b6d23c406
commit a823e968a2
12 changed files with 2022 additions and 4 deletions

19
src/lib/dialects.ts Normal file
View File

@@ -0,0 +1,19 @@
export const DIALECT_LABELS: Record<string, string> = {
ch_be: 'Bern',
ch_bs: 'Basel',
ch_gr: 'Graubünden',
ch_in: 'Innerschweiz',
ch_os: 'Ostschweiz',
ch_vs: 'Wallis',
ch_zh: 'Zürich',
de: 'Deutsch',
};
export type AnnotationEntry = {
id: number;
externalId: string;
fileName: string;
dialect: string;
durationMs: number | null;
datasetId: number;
};

View File

@@ -0,0 +1,36 @@
import { sqliteTable, text, integer, uniqueIndex } from 'drizzle-orm/sqlite-core';
import { relations, sql } from 'drizzle-orm';
import { dataset_entry } from './dataset_entry';
export const annotation = sqliteTable(
'annotation',
{
id: integer('id').primaryKey({ autoIncrement: true }),
datasetEntryId: integer('dataset_entry_id')
.notNull()
.references(() => dataset_entry.id),
userId: text('user_id').notNull(),
rating: integer('rating').notNull(), // 15
dialectLabel: text('dialect_label').notNull(), // e.g. 'ch_be', 'ch_zh', …
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
},
(table) => [
uniqueIndex('annotation_user_entry_dialect_idx').on(
table.userId,
table.datasetEntryId,
table.dialectLabel
),
]
);
export const annotationRelations = relations(annotation, ({ one }) => ({
datasetEntry: one(dataset_entry, {
fields: [annotation.datasetEntryId],
references: [dataset_entry.id],
}),
}));
export type Annotation = typeof annotation.$inferSelect;
export type NewAnnotation = typeof annotation.$inferInsert;