Skip to content

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

feat(audio): retain recent synthesis takes

velixiof021e7b15c45
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ee850650e..2a0dba7c5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,7 +19,7 @@ metadata and the backend fallback mirror it.
### Fixed
-- Older synthesized takes remain playable and Voice Design exposes their History after a new generation (#3102)
+- Recent synthesized takes remain visible and playable, with permanent History exposed in Voice Design (#3102)
- Generated speech no longer starts and ends with silence, and `[pause]` markers give exactly the pause you asked for (Raw preset and explicit durations untouched) (#3080)
- Engine sidecars no longer load PyTorch just to answer the Test Engine ping, and a failed test logs its reason locally (#3026) — thanks @tekay-de!
diff --git a/electron/src/renderer/src/features/clone/output-panel.test.tsx b/electron/src/renderer/src/features/clone/output-panel.test.tsx
index f3470a3cd..2fef97230 100644
--- a/electron/src/renderer/src/features/clone/output-panel.test.tsx
+++ b/electron/src/renderer/src/features/clone/output-panel.test.tsx
@@ -41,16 +41,22 @@ function result(audioPath: string | null): GenerateResult {
}
it('plays a completed take from its persistent audio path instead of a revocable blob URL', () => {
+ const older = result('take-0.wav');
+ const latest = result('take-1.wav');
mocks.output.mockReturnValue({
- result: result('take-1.wav'),
+ result: latest,
objectUrl: 'blob:http://localhost/revoked',
text: 'Hello',
+ takes: [
+ { result: latest, objectUrl: 'blob:http://localhost/latest', text: 'Hello' },
+ { result: older, objectUrl: 'blob:http://localhost/older', text: 'Earlier' },
+ ],
});
render(<OutputPanel />);
- expect(screen.getByTestId('player')).toHaveAttribute(
- 'data-src',
+ expect(screen.getAllByTestId('player').map((player) => player.dataset.src)).toEqual([
'/api/audio/take-1.wav',
- );
+ '/api/audio/take-0.wav',
+ ]);
});
diff --git a/electron/src/renderer/src/features/clone/output-panel.tsx b/electron/src/renderer/src/features/clone/output-panel.tsx
index 3a431e0f9..b9b043a03 100644
--- a/electron/src/renderer/src/features/clone/output-panel.tsx
+++ b/electron/src/renderer/src/features/clone/output-panel.tsx
@@ -13,11 +13,10 @@ import { SectionLabel } from './section-label';
export function OutputPanel() {
const { t } = useTranslation();
- const { result, objectUrl, text } = useLatestOutput();
+ const { result, objectUrl, text, takes } = useLatestOutput();
if (!result || !objectUrl) return null;
const stamp = new Date().toISOString().slice(0, 19).replace(/[:T]/g, '-');
- const playbackUrl = result.audioPath ? audioUrl(result.audioPath) : objectUrl;
return (
<section
@@ -41,7 +40,7 @@ export function OutputPanel() {
aria-label={t('common.close')}
title={t('common.close')}
onClick={() => {
- if (activePlaybackSource() === 'output') stopActivePlayback();
+ if (activePlaybackSource()?.startsWith('output')) stopActivePlayback();
clearLatestOutput();
}}
>
@@ -49,14 +48,23 @@ export function OutputPanel() {
</Button>
</div>
</div>
- {result && playbackUrl ? (
+ {result && objectUrl ? (
<>
- <WaveformPlayer
- key={`player-${playbackUrl}`}
- src={playbackUrl}
- source="output"
- height={36}
- />
+ <div className="flex max-h-64 flex-col gap-2 overflow-y-auto pr-1">
+ {takes.map((take, index) => {
+ const playbackUrl = take.result.audioPath
+ ? audioUrl(take.result.audioPath)
+ : take.objectUrl;
+ return playbackUrl ? (
+ <WaveformPlayer
+ key={take.result.id ?? take.result.audioPath ?? take.objectUrl ?? index}
+ src={playbackUrl}
+ source={index === 0 ? 'output' : `output-${take.result.id ?? index}`}
+ height={36}
+ />
+ ) : null;
+ })}
+ </div>
<AudioFileDetails blob={result.blob} />
{result.audioPath && <AudioQuality audioPath={result.audioPath} />}
<div className="flex flex-wrap items-start justify-between gap-3">
diff --git a/electron/src/renderer/src/lib/store/output.test.ts b/electron/src/renderer/src/lib/store/output.test.ts
new file mode 100644
index 000000000..9cd839d13
--- /dev/null
+++ b/electron/src/renderer/src/lib/store/output.test.ts
@@ -0,0 +1,39 @@
+import { beforeEach, expect, it, vi } from 'vitest';
+import type { GenerateResult } from '@/lib/api/types';
+import { clearLatestOutput, outputStore, setLatestOutput } from './output';
+
+const createObjectURL = vi.fn(() => `blob:take-${createObjectURL.mock.calls.length}`);
+const revokeObjectURL = vi.fn();
+
+function result(id: string): GenerateResult {
+ return {
+ blob: new Blob([id], { type: 'audio/wav' }),
+ id,
+ audioPath: `${id}.wav`,
+ durationSeconds: 1,
+ genTimeSeconds: 2,
+ seed: 3,
+ routing: null,
+ dropped: null,
+ };
+}
+
+beforeEach(() => {
+ Object.assign(URL, { createObjectURL, revokeObjectURL });
+ clearLatestOutput();
+ createObjectURL.mockClear();
+ revokeObjectURL.mockClear();
+});
+
+it('retains earlier session takes until the output history is cleared', () => {
+ setLatestOutput(result('first'), 'First');
+ const firstUrl = outputStore.state.objectUrl;
+ setLatestOutput(result('second'), 'Second');
+
+ expect(outputStore.state.takes.map((take) => take.result.id)).toEqual(['second', 'first']);
+ expect(revokeObjectURL).not.toHaveBeenCalledWith(firstUrl);
+
+ clearLatestOutput();
+ expect(revokeObjectURL).toHaveBeenCalledWith(firstUrl);
+ expect(outputStore.state.takes).toEqual([]);
+});
diff --git a/electron/src/renderer/src/lib/store/output.ts b/electron/src/renderer/src/lib/store/output.ts
index 2078d4893..d76a18d26 100644
--- a/electron/src/renderer/src/lib/store/output.ts
+++ b/electron/src/renderer/src/lib/store/output.ts
@@ -9,20 +9,39 @@ export interface OutputState {
objectUrl: string | null;
/** The script that produced `result`. */
text: string;
+ /** Recent takes from this synthesis session, newest first. */
+ takes: OutputTake[];
}
-export const outputStore = new Store<OutputState>({ result: null, objectUrl: null, text: '' });
+export interface OutputTake {
+ result: GenerateResult;
+ objectUrl: string | null;
+ text: string;
+}
+
+const MAX_SESSION_TAKES = 10;
+
+export const outputStore = new Store<OutputState>({
+ result: null,
+ objectUrl: null,
+ text: '',
+ takes: [],
+});
export function useLatestOutput(): OutputState {
return useStore(outputStore);
}
export function setLatestOutput(result: GenerateResult, text: string): void {
- revokeObjectUrl(outputStore.state.objectUrl);
- outputStore.setState(() => ({ result, objectUrl: createObjectUrl(result.blob), text }));
+ const take = { result, objectUrl: createObjectUrl(result.blob), text };
+ outputStore.setState((state) => {
+ const takes = [take, ...state.takes];
+ for (const dropped of takes.slice(MAX_SESSION_TAKES)) revokeObjectUrl(dropped.objectUrl);
+ return { ...take, takes: takes.slice(0, MAX_SESSION_TAKES) };
+ });
}
export function clearLatestOutput(): void {
- revokeObjectUrl(outputStore.state.objectUrl);
- outputStore.setState(() => ({ result: null, objectUrl: null, text: '' }));
+ for (const take of outputStore.state.takes) revokeObjectUrl(take.objectUrl);
+ outputStore.setState(() => ({ result: null, objectUrl: null, text: '', takes: [] }));
}