style: apply prettier formatting across all source files

This commit is contained in:
2026-05-01 18:36:42 +01:00
parent d60c5ae498
commit a351910fd2
15 changed files with 376 additions and 318 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ export async function POST(request: NextRequest) {
const pythonServerUrl = process.env.VIBEVOICE_SERVER_URL ?? "http://localhost:8000";
try {
const body = await request.json() as {
const body = (await request.json()) as {
text: string;
speaker?: string;
cfg_scale?: number;
@@ -41,7 +41,7 @@ export async function POST(request: NextRequest) {
headers: {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache, no-transform",
"Connection": "keep-alive",
Connection: "keep-alive",
"X-Content-Type-Options": "nosniff",
"X-Accel-Buffering": "no",
},
+1 -2
View File
@@ -4,8 +4,7 @@ const OFFLINE_RESPONSE = { status: "offline" };
const COMMON_OPTIONS = { headers: { "Cache-Control": "no-store" } };
export async function GET() {
const pythonServerUrl =
process.env.VIBEVOICE_SERVER_URL ?? "http://localhost:8000";
const pythonServerUrl = process.env.VIBEVOICE_SERVER_URL ?? "http://localhost:8000";
try {
const res = await fetch(`${pythonServerUrl}/health`, {
+4 -2
View File
@@ -12,8 +12,10 @@
--muted: #64748b;
--success: #22c55e;
--error: #ef4444;
--font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
--font-sans:
ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
--font-mono:
ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@theme inline {
+58 -26
View File
@@ -69,19 +69,39 @@ type AppAction =
function reducer(state: AppState, action: AppAction): AppState {
switch (action.type) {
case "SET_SCRIPT": return { ...state, script: action.payload };
case "SET_SPEAKER": return { ...state, speaker: action.payload };
case "SET_CFG_SCALE": return { ...state, cfgScale: action.payload };
case "SET_INFERENCE_STEPS": return { ...state, inferenceSteps: action.payload };
case "SET_PREBUFFER_SECS": return { ...state, prebufferSecs: action.payload };
case "SET_REBUFFER_THRESHOLD": return { ...state, rebufferThresholdSecs: action.payload };
case "SET_RESUME_THRESHOLD": return { ...state, resumeThresholdSecs: action.payload };
case "SET_SCRIPT":
return { ...state, script: action.payload };
case "SET_SPEAKER":
return { ...state, speaker: action.payload };
case "SET_CFG_SCALE":
return { ...state, cfgScale: action.payload };
case "SET_INFERENCE_STEPS":
return { ...state, inferenceSteps: action.payload };
case "SET_PREBUFFER_SECS":
return { ...state, prebufferSecs: action.payload };
case "SET_REBUFFER_THRESHOLD":
return { ...state, rebufferThresholdSecs: action.payload };
case "SET_RESUME_THRESHOLD":
return { ...state, resumeThresholdSecs: action.payload };
case "START_GENERATION":
return { ...state, isGenerating: true, audioUrl: null, logs: [], genElapsed: 0, genPct: null };
return {
...state,
isGenerating: true,
audioUrl: null,
logs: [],
genElapsed: 0,
genPct: null,
};
case "GEN_PROGRESS":
return { ...state, genElapsed: action.elapsed, genPct: action.pct };
case "GENERATION_SUCCESS":
return { ...state, isGenerating: false, genElapsed: 0, genPct: null, audioUrl: action.payload };
return {
...state,
isGenerating: false,
genElapsed: 0,
genPct: null,
audioUrl: action.payload,
};
case "GENERATION_CANCELLED":
case "GENERATION_ERROR":
return { ...state, isGenerating: false, genElapsed: 0, genPct: null };
@@ -89,21 +109,27 @@ function reducer(state: AppState, action: AppAction): AppState {
return { ...state, logs: [...state.logs, action.payload] };
case "SET_SERVER_STATUS": {
const isNewConfig = !state.serverConfig && action.payload.config;
const deviceChanged = !!(state.serverConfig && action.payload.config && state.serverConfig.device !== action.payload.config.device);
const deviceChanged = !!(
state.serverConfig &&
action.payload.config &&
state.serverConfig.device !== action.payload.config.device
);
const nextSteps = (isNewConfig || deviceChanged)
const nextSteps =
isNewConfig || deviceChanged
? action.payload.config!.default_inference_steps
: state.inferenceSteps;
const nextPrebuffer = (isNewConfig || deviceChanged)
? action.payload.config!.prebuffer_secs
: state.prebufferSecs;
const nextPrebuffer =
isNewConfig || deviceChanged ? action.payload.config!.prebuffer_secs : state.prebufferSecs;
const nextRebuffer = (isNewConfig || deviceChanged)
const nextRebuffer =
isNewConfig || deviceChanged
? action.payload.config!.rebuffer_threshold_secs
: state.rebufferThresholdSecs;
const nextResume = (isNewConfig || deviceChanged)
const nextResume =
isNewConfig || deviceChanged
? action.payload.config!.resume_threshold_secs
: state.resumeThresholdSecs;
@@ -121,7 +147,8 @@ function reducer(state: AppState, action: AppAction): AppState {
resumeThresholdSecs: nextResume,
};
}
default: return state;
default:
return state;
}
}
@@ -213,7 +240,10 @@ export default function HomePage() {
}
poll();
return () => { cancelled = true; clearTimeout(timeoutId); };
return () => {
cancelled = true;
clearTimeout(timeoutId);
};
}, []);
const handleGenerate = useCallback(async () => {
@@ -241,7 +271,6 @@ export default function HomePage() {
<Header />
<main className="flex-1 container mx-auto px-4 py-6 max-w-6xl">
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
{/* Left: script + audio player */}
<div className="lg:col-span-2 flex flex-col gap-6">
<TextInputPanel
@@ -261,12 +290,16 @@ export default function HomePage() {
onCfgScaleChange={(v) => dispatch({ type: "SET_CFG_SCALE", payload: v })}
inferenceSteps={state.inferenceSteps}
onInferenceStepsChange={(v) => dispatch({ type: "SET_INFERENCE_STEPS", payload: v })}
prebufferSecs={state.prebufferSecs}
onPrebufferSecsChange={(v) => dispatch({ type: "SET_PREBUFFER_SECS", payload: v })}
rebufferThresholdSecs={state.rebufferThresholdSecs}
onRebufferThresholdChange={(v) => dispatch({ type: "SET_REBUFFER_THRESHOLD", payload: v })}
resumeThresholdSecs={state.resumeThresholdSecs}
onResumeThresholdChange={(v) => dispatch({ type: "SET_RESUME_THRESHOLD", payload: v })}
prebufferSecs={state.prebufferSecs}
onPrebufferSecsChange={(v) => dispatch({ type: "SET_PREBUFFER_SECS", payload: v })}
rebufferThresholdSecs={state.rebufferThresholdSecs}
onRebufferThresholdChange={(v) =>
dispatch({ type: "SET_REBUFFER_THRESHOLD", payload: v })
}
resumeThresholdSecs={state.resumeThresholdSecs}
onResumeThresholdChange={(v) =>
dispatch({ type: "SET_RESUME_THRESHOLD", payload: v })
}
onGenerate={handleGenerate}
onStop={stop}
onPauseStream={pauseStream}
@@ -281,7 +314,6 @@ export default function HomePage() {
/>
<StatusLog messages={state.logs} />
</div>
</div>
</main>
</div>