openreader/src/types/client.ts
Richard R 199b937a25 refactor: overhaul document storage and audiobook architecture
- refactor(documents): implement stable SHA256-based document IDs
- feat(library): add support for external document libraries
- refactor(audiobook): consolidate server logic and migrate to V1 storage layout
- feat(audiobook): add reset functionality and improve chapter management
- fix(ui): enhance audiobook export modal with download/regenerate controls
- test: add coverage for upload hashing and export reset flow
2026-01-19 14:22:21 -07:00

78 lines
1.7 KiB
TypeScript

import type {
TTSAudiobookChapter,
TTSSentenceAlignment,
TTSAudioBytes,
TTSAudiobookFormat,
} from '@/types/tts';
// --- TTS Client Request Types ---
// Supported output formats for the TTS endpoint
export type TTSRequestFormat = 'mp3';
// JSON payload accepted by the /api/tts endpoint
export interface TTSRequestPayload {
text: string;
voice: string;
speed: number;
model?: string | null;
format?: TTSRequestFormat;
instructions?: string;
}
// Headers used when calling the /api/tts endpoint from the client
export type TTSRequestHeaders = Record<string, string>;
// Options for retrying TTS requests on failure in withRetry
export interface TTSRetryOptions {
maxRetries?: number;
initialDelay?: number;
maxDelay?: number;
backoffFactor?: number;
}
// --- Audiobook API Types ---
export interface AudiobookStatusResponse {
exists: boolean;
chapters: TTSAudiobookChapter[];
bookId: string | null;
hasComplete: boolean;
settings?: AudiobookGenerationSettings | null;
}
export interface AudiobookGenerationSettings {
ttsProvider: string;
ttsModel: string;
voice: string;
nativeSpeed: number;
postSpeed: number;
format: TTSAudiobookFormat;
}
export interface CreateChapterPayload {
chapterTitle: string;
buffer: TTSAudioBytes; // Array.from(new Uint8Array(audioBuffer))
bookId: string;
format: TTSAudiobookFormat;
chapterIndex: number;
settings?: AudiobookGenerationSettings;
}
// --- TTS Voices API Types ---
export interface VoicesResponse {
voices: string[];
}
// --- Whisper API Types ---
export interface AlignmentPayload {
text: string;
audio: TTSAudioBytes; // Array.from(new Uint8Array(arrayBuffer))
}
export interface AlignmentResponse {
alignments: TTSSentenceAlignment[];
}