feat: add new fields to dataset_entry and update related components for processing and display
This commit is contained in:
@@ -53,6 +53,10 @@ export async function downloadFilteredEntries(
|
||||
'id',
|
||||
'audio_file',
|
||||
'duration_ms',
|
||||
'rms_value',
|
||||
'longest_pause',
|
||||
'utmos_score',
|
||||
'wer_score',
|
||||
'utt_id',
|
||||
'text',
|
||||
'speaker',
|
||||
@@ -67,6 +71,10 @@ export async function downloadFilteredEntries(
|
||||
`"${entry.externalId}"`,
|
||||
entry.fileName,
|
||||
entry.durationMs?.toString() || '',
|
||||
entry.rmsValue?.toString() || '',
|
||||
entry.longestPause?.toString() || '',
|
||||
entry.utmosScore?.toString() || '',
|
||||
entry.werScore?.toString() || '',
|
||||
entry.utteranceId || '',
|
||||
`"${(entry.utteranceText || '').replace(/"/g, '""')}"`,
|
||||
entry.speakerId,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import db from '@/lib/db';
|
||||
import { dataset_entry } from '@/lib/model/dataset_entry';
|
||||
import { parseCSVLine } from '@/lib/csv-parser';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { writeFile, mkdir, readFile, rm } from 'fs/promises';
|
||||
@@ -9,41 +10,6 @@ import { join } from 'path';
|
||||
import { existsSync } from 'fs';
|
||||
import { requireAdmin } from '@/lib/auth';
|
||||
|
||||
/**
|
||||
* CSV parser that handles quoted fields
|
||||
*/
|
||||
function parseCSVLine(line: string): string[] {
|
||||
const values: string[] = [];
|
||||
let current = '';
|
||||
let inQuotes = false;
|
||||
|
||||
for (let i = 0; i < line.length; i++) {
|
||||
const char = line[i];
|
||||
const nextChar = line[i + 1];
|
||||
|
||||
if (char === '"') {
|
||||
if (inQuotes && nextChar === '"') {
|
||||
// Escaped quote
|
||||
current += '"';
|
||||
i++;
|
||||
} else {
|
||||
// Toggle quote state
|
||||
inQuotes = !inQuotes;
|
||||
}
|
||||
} else if (char === ',' && !inQuotes) {
|
||||
// Field separator
|
||||
values.push(current.trim());
|
||||
current = '';
|
||||
} else {
|
||||
current += char;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the last field
|
||||
values.push(current.trim());
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Process the extracted ZIP data and insert into database
|
||||
* Copies audio files and creates database entries
|
||||
@@ -137,6 +103,10 @@ export async function processDatasetEntries(
|
||||
dialect: row.dialect,
|
||||
iteration: parseInt(row.iteration, 10),
|
||||
durationMs: row.duration_ms ? parseInt(row.duration_ms, 10) : undefined,
|
||||
rmsValue: row.rms_value ? parseFloat(row.rms_value) : undefined,
|
||||
longestPause: row.longest_pause ? parseFloat(row.longest_pause) : undefined,
|
||||
utmosScore: row.utmos_score ? parseFloat(row.utmos_score) : undefined,
|
||||
werScore: row.wer_score ? parseFloat(row.wer_score) : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,26 @@ export default async function DatasetEntryPage({ params }: DatasetEntryPageProps
|
||||
<p className="text-lg font-semibold">{entry.durationMs?.toLocaleString() || '-'}</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-white border border-gray-200 p-4 rounded-lg">
|
||||
<p className="text-sm text-gray-600 mb-1">RMS Value</p>
|
||||
<p className="text-lg font-semibold">{entry.rmsValue?.toFixed(3) || '-'}</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-white border border-gray-200 p-4 rounded-lg">
|
||||
<p className="text-sm text-gray-600 mb-1">Longest Pause (s)</p>
|
||||
<p className="text-lg font-semibold">{entry.longestPause?.toFixed(3) || '-'}</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-white border border-gray-200 p-4 rounded-lg">
|
||||
<p className="text-sm text-gray-600 mb-1">UTMOS Score</p>
|
||||
<p className="text-lg font-semibold">{entry.utmosScore?.toFixed(3) || '-'}</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-white border border-gray-200 p-4 rounded-lg">
|
||||
<p className="text-sm text-gray-600 mb-1">WER Score</p>
|
||||
<p className="text-lg font-semibold">{entry.werScore?.toFixed(3) || '-'}</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-white border border-gray-200 p-4 rounded-lg">
|
||||
<p className="text-sm text-gray-600 mb-1">Created</p>
|
||||
<p className="text-lg font-semibold">
|
||||
|
||||
Reference in New Issue
Block a user