import * as _storyteller_platform_ghost_story from '@storyteller-platform/ghost-story'; import { Logger } from 'pino'; import { Epub } from '@storyteller-platform/epub'; import { RecognitionResult } from '@storyteller-platform/ghost-story/recognition'; import { StorytellerTranscription } from './getSentenceRanges.js'; import '@echogarden/text-segmentation'; import '@storyteller-platform/mapping'; interface AudioFileContext { start: number; end: number; filepath: string; } interface ChapterReport { href: string; transcriptionOffset: number; endTranscriptionOffset: number; transcriptionContext: { before: string; after: string; }; endTranscriptionContext: { before: string; after: string; }; firstMatchedSentenceId: number; firstMatchedSentenceContext: { prevSentence: string | null; matchedSentence: string; nextSentence: string | null; }; lastMatchedSentenceId: number; lastMatchedSentenceContext: { prevSentence: string | null; matchedSentence: string; nextSentence: string | null; }; chapterSentenceCount: number; alignedSentenceCount: number; audioFiles: AudioFileContext[]; } type UnalignedChapterReason = "too-short" | "not-found" | "is-nav" | "no-text"; interface UnalignedChapterReport { href: string; reason: Exclude; } interface UnalignedNotFoundChapterReport { href: string; reason: "not-found"; start: string; end: string; } interface AudioFileReport { filepath: string; matchedRanges: { start: number; end: number; }[]; duration: number; alignedDuration: number; } interface UnalignedAudioFileReport { filepath: string; } interface Report { chapters: ChapterReport[]; unalignedChapters: (UnalignedChapterReport | UnalignedNotFoundChapterReport)[]; audioFiles: AudioFileReport[]; unalignedAudioFiles: UnalignedAudioFileReport[]; } interface AlignOptions { reportsPath?: string | null | undefined; granularity?: "sentence" | "word" | null | undefined; textRef?: "id-fragment" | "text-fragment" | null | undefined; outFormat?: "epub" | "gnp" | null | undefined; primaryLocale?: Intl.Locale | null | undefined; logger?: Logger | null | undefined; onProgress?: ((progress: number) => void) | null | undefined; } declare function align(input: string, output: string, transcriptionsDir: string, audiobookDir: string, options: AlignOptions): Promise<_storyteller_platform_ghost_story.TimingAggregator>; declare class Aligner { epub: Epub; private audiofiles; private languageOverride?; private logger?; private transcription; private totalDuration; private alignedChapters; private timing; private granularity; private textRef; private audioFileDurations; report: Report; constructor(epub: Epub, audiofiles: string[], transcriptions: Pick[], granularity: "sentence" | "word" | null | undefined, textRef: "id-fragment" | "text-fragment" | null | undefined, languageOverride?: (Intl.Locale | null) | undefined, logger?: (Logger | null) | undefined); private getChapterSentences; private writeAlignedChapter; private addChapterReport; private alignChapter; narrowToAvailableBoundary(boundary: { start: number; end: number; }): { start: number; end: number; }; alignBook(onProgress?: ((progress: number) => void) | null): Promise<_storyteller_platform_ghost_story.TimingAggregator>; } declare function concatTranscriptions(transcriptions: Pick[], audiofiles: string[]): StorytellerTranscription; export { type AlignOptions, Aligner, align, concatTranscriptions };