untitled-5961Toast.tsx1 match
104105// Toast Hook
106export function useToast() {
107const [toasts, setToasts] = useState<ToastMessage[]>([]);
108
17}
1819export function useFileProcessor() {
20const [state, setState] = useState<FileProcessorState>({
21isProcessing: false,
untitled-5961useTTS.ts4 matches
1// hooks/useTTS.ts - TTS functionality with background processing and queue management
2import { useCallback, useEffect, useRef, useState } from "react";
3import { ttsCache } from "../lib/ttsCache";
20}
2122export function useTTS() {
23const [state, setState] = useState<TTSState>({
24voices: [],
383}
384385// Helper function to estimate audio duration
386function estimateDuration(text: string, rate: number = 1): number {
387const wordsPerMinute = 150 * rate; // Base rate adjusted by speed
388const wordCount = text.split(/\s+/).length;
untitled-5961useLibrary.ts2 matches
4import { AudioChunk, Collection, LibraryItem, ProcessedDocument } from "../lib/types";
56export function useLibrary() {
7const [items, setItems] = useState<LibraryItem[]>([]);
8const [collections, setCollections] = useState<Collection[]>([]);
277}, []);
278279// Export/Import functionality
280const exportLibrary = useCallback(async (): Promise<string> => {
281try {
15}
1617export function useAudioPlayer() {
18const [state, setState] = useState<AudioPlayerState>({
19isPlaying: false,
untitled-5961tts.ts9 matches
25}
2627export default async function handler(req: Request, context: HandlerContext) {
28const { method } = req;
29const url = new URL(req.url);
77* Handle voice list requests
78*/
79async function handleGetVoices(req: Request, headers: Headers): Promise<Response> {
80const url = new URL(req.url);
81const apiKey = url.searchParams.get("apiKey");
139* Handle single text synthesis
140*/
141async function handleSynthesize(req: Request, headers: Headers): Promise<Response> {
142const requestData: TTSRequest = await req.json();
143const { text, voice, settings, apiKey, chunkId } = requestData;
205* Handle batch synthesis for multiple chunks
206*/
207async function handleBatchSynthesize(req: Request, headers: Headers): Promise<Response> {
208const { chunks, voice, settings, apiKey } = await req.json() as {
209chunks: Array<{ id: string; text: string }>;
282* Synthesize text with Google TTS API
283*/
284async function synthesizeWithGoogle(
285text: string,
286voice: TTSVoice,
344* Get voice quality tier
345*/
346function getVoiceQuality(voiceName: string): string {
347if (voiceName.includes("Studio")) return "studio";
348if (voiceName.includes("Wavenet")) return "wavenet";
354* Get voice pricing information
355*/
356function getVoicePricing(voiceName: string): {
357tier: string;
358pricePerMillionChars: number;
375* Estimate audio duration based on text and speaking rate
376*/
377function estimateAudioDuration(text: string, rate: number = 1): number {
378const wordsPerMinute = 150 * rate; // Base rate of 150 WPM
379const wordCount = text.split(/\s+/).length;
384* Generate unique chunk ID
385*/
386function generateChunkId(): string {
387return `chunk_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
388}
untitled-5961audioUtils.ts1 match
34/**
5* Audio utility functions for processing, combining, and analyzing audio data
6*/
7export class AudioUtils {
untitled-5961ttsCache.ts3 matches
2728/**
29* Simple hash function for text
30*/
31private hashCode(str: string): number {
180voice: TTSVoice,
181settings: TTSSettings,
182synthesizeFunction: (text: string, voice: TTSVoice, settings: TTSSettings) => Promise<string>,
183): Promise<void> {
184const prefetchPromises = texts
187.map(async text => {
188try {
189const audioData = await synthesizeFunction(text, voice, settings);
190await this.set(text, voice, settings, audioData);
191} catch (error) {
10import hanabi from "https://esm.town/v/jxnblk/hanabi/main.tsx";
1112function Home () {
13return (
14<div>
20}
2122function About () {
23return (
24<div>