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>
2021- `main.tsx`: The main application file with Hono routes and UI components
22- `utils.tsx`: Utility functions for Switchbot API authentication and requests
23- `styles.tsx`: CSS styles for the web interface
FullstackStarterhome.tsx1 match
3import { Link } from "https://esm.sh/react-router@7";
45export function Component() {
6return (
7<div className="flex flex-col items-center justify-center min-h-[50vh]">
FullstackStarterindex.tsx2 matches
45// HTML wrapper component
6function HTML({ children }: { children: React.ReactNode }) {
7return (
8<html lang="en">
2324// Root layout component
25export function Component() {
26return (
27<HTML>
26};
2728// --- Helper Functions ---
29async function hashPassword(password) {
30const encoder = new TextEncoder();
31const data = encoder.encode(password);
3738// --- Main App Component ---
39function App() {
40const [user, setUser] = useState(null);
41// Add 'profile' and 'task' to the possible views
460Client-side Entry Point
461==========================*/
462function client() {
463const rootElement = document.getElementById("root");
464if (rootElement) {
476Server-side Logic
477==========================*/
478export default async function server(
479request, /*: Request // Removed type for broader compatibility if not in TS env */
480) /*: Promise<Response>*/ {
1810if (path === "/" && method === "GET") {
1811// The module script src will be this file itself.
1812// The client() function will be called.
1813// The component imports like "./components/login.tsx" will be resolved by the environment
1814// (e.g., Val Town's bundler or a local dev server/bundler).
FullstackStarterroutes.tsx2 matches
5import { Home } from "./frontend/routes/Home.tsx";
67function HTML({ children }: { children: React.ReactNode }) {
8return (
9<html lang="en">
23}
2425function Layout() {
26return (
27<HTML>