Replace the previous whisper.cpp-based word alignment with a fully ONNX-based implementation using onnxruntime-node and @huggingface/tokenizers. Add new Whisper ONNX model management, alignment mapping, and spectral analysis modules. Remove all code and documentation referencing whisper.cpp, update environment variables, Dockerfile, and docs to reflect ONNX-only alignment. Add unit tests for alignment and ONNX model logic.
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import type { NextConfig } from "next";
|
|
|
|
const securityHeaders = [
|
|
{ key: 'X-Content-Type-Options', value: 'nosniff' },
|
|
{ key: 'X-Frame-Options', value: 'SAMEORIGIN' },
|
|
{
|
|
key: 'Content-Security-Policy',
|
|
value: "frame-ancestors 'self' https://*.huggingface.co https://huggingface.co",
|
|
},
|
|
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
|
|
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
|
|
{
|
|
key: 'Strict-Transport-Security',
|
|
value: 'max-age=63072000; includeSubDomains; preload',
|
|
},
|
|
];
|
|
const nextConfig: NextConfig = {
|
|
async headers() {
|
|
return [
|
|
{
|
|
// Apply security headers to all routes
|
|
source: '/(.*)',
|
|
headers: securityHeaders,
|
|
},
|
|
];
|
|
},
|
|
turbopack: {
|
|
resolveAlias: {
|
|
canvas: '@napi-rs/canvas',
|
|
},
|
|
},
|
|
serverExternalPackages: [
|
|
"@napi-rs/canvas",
|
|
"ffmpeg-static",
|
|
"better-sqlite3",
|
|
"onnxruntime-node",
|
|
"@huggingface/tokenizers",
|
|
],
|
|
outputFileTracingIncludes: {
|
|
'/api/audiobook': [
|
|
'./node_modules/ffmpeg-static/ffmpeg',
|
|
],
|
|
'/api/audiobook/chapter': [
|
|
'./node_modules/ffmpeg-static/ffmpeg',
|
|
],
|
|
'/api/tts/segments/ensure': [
|
|
'./node_modules/ffmpeg-static/ffmpeg',
|
|
],
|
|
'/api/documents/blob/preview/ensure': [
|
|
'./node_modules/pdfjs-dist/legacy/build/pdf.worker.mjs',
|
|
],
|
|
'/api/documents/blob/preview/presign': [
|
|
'./node_modules/pdfjs-dist/legacy/build/pdf.worker.mjs',
|
|
],
|
|
'/api/documents/blob/preview/fallback': [
|
|
'./node_modules/pdfjs-dist/legacy/build/pdf.worker.mjs',
|
|
],
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|