- Introduce `/api/whisper` endpoint which uses `whisper.cpp` (via a `WHISPER_CPP_BIN` executable) and `ffmpeg` to generate word-level audio alignments from provided audio and text. - Integrate word-level alignments into `TTSContext`, tracking the currently spoken word based on audio seek position and provided timestamps. Alignments are cached in-memory and fetched asynchronously. - Add new configuration options (`pdfWordHighlightEnabled`, `epubWordHighlightEnabled`) to `ConfigContext` and `Dexie` for enabling/disabling the feature. - Implement visual word highlighting in both `PDFViewer` and `EPUBViewer` by mapping TTS-aligned words to rendered text elements. - Enhance `EPUBContext` and `PDFContext` with new `highlightWordIndex` and `clearWordHighlights` functions, utilizing fuzzy string matching (`cmpstr`) to robustly align spoken words with displayed text for accurate highlighting. - Update `DocumentSettings` to include user-facing toggles for the new highlighting modes.
67 lines
1.5 KiB
TypeScript
67 lines
1.5 KiB
TypeScript
import type { DocumentListState } from '@/types/documents';
|
|
|
|
export type ViewType = 'single' | 'dual' | 'scroll';
|
|
|
|
export type SavedVoices = Record<string, string>;
|
|
|
|
export interface AppConfigValues {
|
|
apiKey: string;
|
|
baseUrl: string;
|
|
viewType: ViewType;
|
|
voiceSpeed: number;
|
|
audioPlayerSpeed: number;
|
|
voice: string;
|
|
skipBlank: boolean;
|
|
epubTheme: boolean;
|
|
headerMargin: number;
|
|
footerMargin: number;
|
|
leftMargin: number;
|
|
rightMargin: number;
|
|
ttsProvider: string;
|
|
ttsModel: string;
|
|
ttsInstructions: string;
|
|
savedVoices: SavedVoices;
|
|
smartSentenceSplitting: boolean;
|
|
pdfHighlightEnabled: boolean;
|
|
pdfWordHighlightEnabled: boolean;
|
|
epubHighlightEnabled: boolean;
|
|
epubWordHighlightEnabled: boolean;
|
|
firstVisit: boolean;
|
|
documentListState: DocumentListState;
|
|
}
|
|
|
|
export const APP_CONFIG_DEFAULTS: AppConfigValues = {
|
|
apiKey: '',
|
|
baseUrl: '',
|
|
viewType: 'single',
|
|
voiceSpeed: 1,
|
|
audioPlayerSpeed: 1,
|
|
voice: '',
|
|
skipBlank: true,
|
|
epubTheme: false,
|
|
headerMargin: 0,
|
|
footerMargin: 0,
|
|
leftMargin: 0,
|
|
rightMargin: 0,
|
|
ttsProvider: 'custom-openai',
|
|
ttsModel: 'kokoro',
|
|
ttsInstructions: '',
|
|
savedVoices: {},
|
|
smartSentenceSplitting: true,
|
|
pdfHighlightEnabled: true,
|
|
pdfWordHighlightEnabled: true,
|
|
epubHighlightEnabled: true,
|
|
epubWordHighlightEnabled: true,
|
|
firstVisit: false,
|
|
documentListState: {
|
|
sortBy: 'name',
|
|
sortDirection: 'asc',
|
|
folders: [],
|
|
collapsedFolders: [],
|
|
showHint: true,
|
|
},
|
|
};
|
|
|
|
export interface AppConfigRow extends AppConfigValues {
|
|
id: string;
|
|
}
|