Skip to content

The open-source AI voice studio. Clone, dictate, create.

feat: add auto-chunking limit slider to settings

James Pine837f8525d89a
diff --git a/app/src/components/ServerSettings/ConnectionForm.tsx b/app/src/components/ServerSettings/ConnectionForm.tsx
index 44eeb4e6..a5521870 100644
--- a/app/src/components/ServerSettings/ConnectionForm.tsx
+++ b/app/src/components/ServerSettings/ConnectionForm.tsx
@@ -4,6 +4,7 @@ import { useForm } from 'react-hook-form';
import * as z from 'zod';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Checkbox } from '@/components/ui/checkbox';
import {
Form,
FormControl,
@@ -14,10 +15,10 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { Checkbox } from '@/components/ui/checkbox';
+import { Slider } from '@/components/ui/slider';
import { useToast } from '@/components/ui/use-toast';
-import { useServerStore } from '@/stores/serverStore';
import { usePlatform } from '@/platform/PlatformContext';
+import { useServerStore } from '@/stores/serverStore';
const connectionSchema = z.object({
serverUrl: z.string().url('Please enter a valid URL'),
@@ -33,6 +34,8 @@ export function ConnectionForm() {
const setKeepServerRunningOnClose = useServerStore((state) => state.setKeepServerRunningOnClose);
const mode = useServerStore((state) => state.mode);
const setMode = useServerStore((state) => state.setMode);
+ const maxChunkChars = useServerStore((state) => state.maxChunkChars);
+ const setMaxChunkChars = useServerStore((state) => state.setMaxChunkChars);
const { toast } = useToast();
const form = useForm<ConnectionFormValues>({
@@ -59,11 +62,7 @@ export function ConnectionForm() {
}
return (
- <Card
- role="region"
- aria-label="Server Connection"
- tabIndex={0}
- >
+ <Card role="region" aria-label="Server Connection" tabIndex={0}>
<CardHeader>
<CardTitle>Server Connection</CardTitle>
</CardHeader>
@@ -153,6 +152,32 @@ export function ConnectionForm() {
</div>
</div>
)}
+
+ <div className="mt-6 pt-6 border-t">
+ <div className="space-y-3">
+ <div className="flex items-center justify-between">
+ <label htmlFor="maxChunkChars" className="text-sm font-medium leading-none">
+ Auto-chunking limit
+ </label>
+ <span className="text-sm tabular-nums text-muted-foreground">
+ {maxChunkChars} chars
+ </span>
+ </div>
+ <Slider
+ id="maxChunkChars"
+ value={[maxChunkChars]}
+ onValueChange={([value]) => setMaxChunkChars(value)}
+ min={100}
+ max={2000}
+ step={50}
+ aria-label="Auto-chunking character limit"
+ />
+ <p className="text-sm text-muted-foreground">
+ Long text is split into chunks at sentence boundaries before generating. Lower values
+ can improve quality for long outputs. Default is 800.
+ </p>
+ </div>
+ </div>
</CardContent>
</Card>
);
diff --git a/app/src/lib/api/types.ts b/app/src/lib/api/types.ts
index fe5f05a1..d8ad6b13 100644
--- a/app/src/lib/api/types.ts
+++ b/app/src/lib/api/types.ts
@@ -36,6 +36,7 @@ export interface GenerationRequest {
model_size?: '1.7B' | '0.6B';
engine?: 'qwen' | 'luxtts' | 'chatterbox' | 'chatterbox_turbo';
instruct?: string;
+ max_chunk_chars?: number;
}
export interface GenerationResponse {
diff --git a/app/src/lib/hooks/useGenerationForm.ts b/app/src/lib/hooks/useGenerationForm.ts
index 5a83ce41..e1244d22 100644
--- a/app/src/lib/hooks/useGenerationForm.ts
+++ b/app/src/lib/hooks/useGenerationForm.ts
@@ -9,9 +9,10 @@ import { useGeneration } from '@/lib/hooks/useGeneration';
import { useModelDownloadToast } from '@/lib/hooks/useModelDownloadToast';
import { useGenerationStore } from '@/stores/generationStore';
import { usePlayerStore } from '@/stores/playerStore';
+import { useServerStore } from '@/stores/serverStore';
const generationSchema = z.object({
- text: z.string().min(1, 'Text is required').max(5000),
+ text: z.string().min(1, 'Text is required').max(50000),
language: z.enum(LANGUAGE_CODES as [LanguageCode, ...LanguageCode[]]),
seed: z.number().int().optional(),
modelSize: z.enum(['1.7B', '0.6B']).optional(),
@@ -31,6 +32,7 @@ export function useGenerationForm(options: UseGenerationFormOptions = {}) {
const generation = useGeneration();
const setAudioWithAutoPlay = usePlayerStore((state) => state.setAudioWithAutoPlay);
const setIsGenerating = useGenerationStore((state) => state.setIsGenerating);
+ const maxChunkChars = useServerStore((state) => state.maxChunkChars);
const [downloadingModelName, setDownloadingModelName] = useState<string | null>(null);
const [downloadingDisplayName, setDownloadingDisplayName] = useState<string | null>(null);
@@ -110,6 +112,7 @@ export function useGenerationForm(options: UseGenerationFormOptions = {}) {
model_size: isQwen ? data.modelSize : undefined,
engine,
instruct: isQwen ? data.instruct || undefined : undefined,
+ max_chunk_chars: maxChunkChars,
});
toast({
diff --git a/app/src/stores/serverStore.ts b/app/src/stores/serverStore.ts
index 36d9f0af..9d4ad89c 100644
--- a/app/src/stores/serverStore.ts
+++ b/app/src/stores/serverStore.ts
@@ -13,6 +13,9 @@ interface ServerStore {
keepServerRunningOnClose: boolean;
setKeepServerRunningOnClose: (keepRunning: boolean) => void;
+
+ maxChunkChars: number;
+ setMaxChunkChars: (value: number) => void;
}
export const useServerStore = create<ServerStore>()(
@@ -29,6 +32,9 @@ export const useServerStore = create<ServerStore>()(
keepServerRunningOnClose: false,
setKeepServerRunningOnClose: (keepRunning) => set({ keepServerRunningOnClose: keepRunning }),
+
+ maxChunkChars: 800,
+ setMaxChunkChars: (value) => set({ maxChunkChars: value }),
}),
{
name: 'voicebox-server',