Skip to content

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

feat(app): export dropdown for stories (WAV/MP3/M4B) and MP3 export in history

jamiepine37aa4234ce12
diff --git a/app/src/components/History/HistoryTable.tsx b/app/src/components/History/HistoryTable.tsx
index aeeae4ec..575e3b91 100644
--- a/app/src/components/History/HistoryTable.tsx
+++ b/app/src/components/History/HistoryTable.tsx
@@ -43,7 +43,12 @@ import {
import { Textarea } from '@/components/ui/textarea';
import { useToast } from '@/components/ui/use-toast';
import { apiClient } from '@/lib/api/client';
-import type { EffectConfig, GenerationVersionResponse, HistoryResponse } from '@/lib/api/types';
+import type {
+ EffectConfig,
+ GenerationExportFormat,
+ GenerationVersionResponse,
+ HistoryResponse,
+} from '@/lib/api/types';
import { BOTTOM_SAFE_AREA_PADDING } from '@/lib/constants/ui';
import {
useClearFailedGenerations,
@@ -214,9 +219,13 @@ export function HistoryTable() {
}
};
- const handleDownloadAudio = (generationId: string, text: string) => {
+ const handleDownloadAudio = (
+ generationId: string,
+ text: string,
+ format: GenerationExportFormat = 'wav',
+ ) => {
exportGenerationAudio.mutate(
- { generationId, text },
+ { generationId, text, format },
{
onError: (error) => {
toast({
@@ -663,6 +672,13 @@ export function HistoryTable() {
<Download className="mr-2 h-4 w-4" />
{t('history.actions.exportAudio')}
</DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => handleDownloadAudio(gen.id, gen.text, 'mp3')}
+ disabled={exportGenerationAudio.isPending}
+ >
+ <Download className="mr-2 h-4 w-4" />
+ {t('history.actions.exportAudioMp3')}
+ </DropdownMenuItem>
<DropdownMenuItem
onClick={() => handleExportPackage(gen.id, gen.text)}
disabled={exportGeneration.isPending}
diff --git a/app/src/components/StoriesTab/StoryContent.tsx b/app/src/components/StoriesTab/StoryContent.tsx
index 3f19d81d..53c8e79a 100644
--- a/app/src/components/StoriesTab/StoryContent.tsx
+++ b/app/src/components/StoriesTab/StoryContent.tsx
@@ -15,15 +15,24 @@ import {
} from '@dnd-kit/sortable';
import { Link } from '@tanstack/react-router';
import { AnimatePresence, motion } from 'framer-motion';
-import { Download, Music, Plus, Upload } from 'lucide-react';
+import { BookAudio, ChevronDown, Download, FileAudio, Music, Plus, Upload } from 'lucide-react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import Loader from 'react-loaders';
import { Button } from '@/components/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
import { Input } from '@/components/ui/input';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { useToast } from '@/components/ui/use-toast';
import { apiClient } from '@/lib/api/client';
+import type { StoryExportFormat } from '@/lib/api/types';
import { useHistory } from '@/lib/hooks/useHistory';
import {
useAddStoryItem,
@@ -213,13 +222,14 @@ export function StoryContent() {
);
};
- const handleExportAudio = () => {
+ const handleExportAudio = (format: StoryExportFormat) => {
if (!story) return;
exportAudio.mutate(
{
storyId: story.id,
storyName: story.name,
+ format,
},
{
onError: (error) => {
@@ -446,15 +456,33 @@ export function StoryContent() {
</PopoverContent>
</Popover>
{story.items.length > 0 && (
- <Button
- variant="outline"
- size="sm"
- onClick={handleExportAudio}
- disabled={exportAudio.isPending}
- >
- <Download className="mr-2 h-4 w-4" />
- {t('storyContent.exportAudio')}
- </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="sm" disabled={exportAudio.isPending}>
+ <Download className="mr-2 h-4 w-4" />
+ {t('storyContent.exportAudio')}
+ <ChevronDown className="ml-1 h-3.5 w-3.5 opacity-70" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-60">
+ <DropdownMenuLabel className="text-[11px] font-medium text-muted-foreground uppercase tracking-wide">
+ {t('storyContent.exportDropdownLabel')}
+ </DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={() => handleExportAudio('wav')}>
+ <FileAudio className="mr-2 h-3.5 w-3.5 text-muted-foreground" />
+ {t('storyContent.exportFormats.wav')}
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => handleExportAudio('mp3')}>
+ <FileAudio className="mr-2 h-3.5 w-3.5 text-muted-foreground" />
+ {t('storyContent.exportFormats.mp3')}
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => handleExportAudio('m4b')}>
+ <BookAudio className="mr-2 h-3.5 w-3.5 text-muted-foreground" />
+ {t('storyContent.exportFormats.m4b')}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
)}
</div>
</div>
diff --git a/app/src/i18n/locales/en/translation.json b/app/src/i18n/locales/en/translation.json
index 58186f53..c5055c95 100644
--- a/app/src/i18n/locales/en/translation.json
+++ b/app/src/i18n/locales/en/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "No matching generations found",
"searchNoAvailable": "No available generations",
"exportAudio": "Export Audio",
+ "exportDropdownLabel": "Export story as",
+ "exportFormats": {
+ "wav": "Audio (WAV)",
+ "mp3": "Audio (MP3)",
+ "m4b": "Audiobook (M4B, chapters)"
+ },
"empty": {
"title": "No items in this story",
"hint": "Generate speech using the box below to add items"
@@ -650,6 +656,7 @@
"menu": "Actions",
"play": "Play",
"exportAudio": "Export Audio",
+ "exportAudioMp3": "Export Audio (MP3)",
"exportPackage": "Export Package",
"applyEffects": "Apply Effects",
"regenerate": "Regenerate"
@@ -1143,7 +1150,8 @@
"title": "Switch to CPU backend",
"description": "Disable GPU acceleration. You can re-download the GPU backend later.",
"button": "Switch"
- }, "remove": {
+ },
+ "remove": {
"title": "Remove CUDA backend",
"description": "Delete the downloaded CUDA binary to free disk space.",
"button": "Remove"
diff --git a/app/src/i18n/locales/es/translation.json b/app/src/i18n/locales/es/translation.json
index 9d2d851e..cc0078d3 100644
--- a/app/src/i18n/locales/es/translation.json
+++ b/app/src/i18n/locales/es/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "No se encontraron generaciones coincidentes",
"searchNoAvailable": "No hay generaciones disponibles",
"exportAudio": "Exportar audio",
+ "exportDropdownLabel": "Exportar historia como",
+ "exportFormats": {
+ "wav": "Audio (WAV)",
+ "mp3": "Audio (MP3)",
+ "m4b": "Audiolibro (M4B, capítulos)"
+ },
"empty": {
"title": "No hay elementos en esta historia",
"hint": "Genera voz con el cuadro de abajo para añadir elementos"
@@ -650,6 +656,7 @@
"menu": "Acciones",
"play": "Reproducir",
"exportAudio": "Exportar audio",
+ "exportAudioMp3": "Exportar audio (MP3)",
"exportPackage": "Exportar paquete",
"applyEffects": "Aplicar efectos",
"regenerate": "Regenerar"
diff --git a/app/src/i18n/locales/fr/translation.json b/app/src/i18n/locales/fr/translation.json
index f2af10b2..4f70f69e 100644
--- a/app/src/i18n/locales/fr/translation.json
+++ b/app/src/i18n/locales/fr/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "Aucune génération correspondante trouvée",
"searchNoAvailable": "Aucune génération disponible",
"exportAudio": "Exporter l'audio",
+ "exportDropdownLabel": "Exporter l'histoire en",
+ "exportFormats": {
+ "wav": "Audio (WAV)",
+ "mp3": "Audio (MP3)",
+ "m4b": "Livre audio (M4B, chapitres)"
+ },
"empty": {
"title": "Aucun élément dans cette histoire",
"hint": "Générez de la parole avec la zone ci-dessous pour ajouter des éléments"
@@ -650,6 +656,7 @@
"menu": "Actions",
"play": "Lire",
"exportAudio": "Exporter l'audio",
+ "exportAudioMp3": "Exporter l'audio (MP3)",
"exportPackage": "Exporter le package",
"applyEffects": "Appliquer les effets",
"regenerate": "Régénérer"
@@ -760,8 +767,13 @@
}
},
"general": {
- "docs": { "title": "Lire la documentation" },
- "discord": { "title": "Rejoindre le Discord", "subtitle": "Obtenez de l'aide et partagez des voix" },
+ "docs": {
+ "title": "Lire la documentation"
+ },
+ "discord": {
+ "title": "Rejoindre le Discord",
+ "subtitle": "Obtenez de l'aide et partagez des voix"
+ },
"serverUrl": {
"title": "URL du serveur",
"description": "L'adresse de votre serveur Voicebox.",
diff --git a/app/src/i18n/locales/it/translation.json b/app/src/i18n/locales/it/translation.json
index e63a296e..20968ac1 100644
--- a/app/src/i18n/locales/it/translation.json
+++ b/app/src/i18n/locales/it/translation.json
@@ -379,7 +379,7 @@
"play": "Riproduci campione",
"pause": "Pausa campione",
"stop": "Interrompi",
- "stopAria": "Interrompi riproduzione",
+ "stopAria": "Interrompi riproduzione",
"position": "Posizione riproduzione campione",
"positionValue": "{{current}} di {{total}}"
},
@@ -623,6 +623,12 @@
"searchNoMatches": "Nessuna generazione corrispondente trovata",
"searchNoAvailable": "Nessuna generazione disponibile",
"exportAudio": "Esporta audio",
+ "exportDropdownLabel": "Esporta storia come",
+ "exportFormats": {
+ "wav": "Audio (WAV)",
+ "mp3": "Audio (MP3)",
+ "m4b": "Audiolibro (M4B, capitoli)"
+ },
"empty": {
"title": "Nessun elemento in questa storia",
"hint": "Genera del testo parlato utilizzando la casella sottostante per aggiungere elementi"
@@ -650,6 +656,7 @@
"menu": "Azioni",
"play": "Riproduci",
"exportAudio": "Esporta audio",
+ "exportAudioMp3": "Esporta audio (MP3)",
"exportPackage": "Esporta pacchetto",
"applyEffects": "Applica effetti",
"regenerate": "Rigenera"
@@ -1124,7 +1131,8 @@
"title": "Passa al backend CPU",
"description": "Disabilita l'accelerazione GPU. Potrai scaricare nuovamente il backend GPU in un secondo momento.",
"button": "Passa a CPU"
- }, "remove": {
+ },
+ "remove": {
"title": "Rimuovi il backend CUDA",
"description": "Elimina il file binario CUDA scaricato per liberare spazio sul disco.",
"button": "Rimuovi"
diff --git a/app/src/i18n/locales/ja/translation.json b/app/src/i18n/locales/ja/translation.json
index 5ae4c514..fbecac90 100644
--- a/app/src/i18n/locales/ja/translation.json
+++ b/app/src/i18n/locales/ja/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "一致する生成が見つかりません",
"searchNoAvailable": "利用可能な生成がありません",
"exportAudio": "オーディオをエクスポート",
+ "exportDropdownLabel": "ストーリーをエクスポート",
+ "exportFormats": {
+ "wav": "音声 (WAV)",
+ "mp3": "音声 (MP3)",
+ "m4b": "オーディオブック (M4B、チャプター付き)"
+ },
"empty": {
"title": "このストーリーには項目がありません",
"hint": "下のボックスで音声を生成して項目を追加します"
@@ -650,6 +656,7 @@
"menu": "操作",
"play": "再生",
"exportAudio": "オーディオをエクスポート",
+ "exportAudioMp3": "オーディオをエクスポート (MP3)",
"exportPackage": "パッケージをエクスポート",
"applyEffects": "エフェクトを適用",
"regenerate": "再生成"
@@ -760,8 +767,13 @@
}
},
"general": {
- "docs": { "title": "ドキュメントを読む" },
- "discord": { "title": "Discord に参加", "subtitle": "ヘルプやボイスの共有" },
+ "docs": {
+ "title": "ドキュメントを読む"
+ },
+ "discord": {
+ "title": "Discord に参加",
+ "subtitle": "ヘルプやボイスの共有"
+ },
"serverUrl": {
"title": "サーバー URL",
"description": "Voicebox バックエンドサーバーのアドレス。",
diff --git a/app/src/i18n/locales/ko/translation.json b/app/src/i18n/locales/ko/translation.json
index 88d438dd..77421d6c 100644
--- a/app/src/i18n/locales/ko/translation.json
+++ b/app/src/i18n/locales/ko/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "일치하는 생성물이 없습니다",
"searchNoAvailable": "사용 가능한 생성물이 없습니다",
"exportAudio": "오디오 내보내기",
+ "exportDropdownLabel": "스토리 내보내기 형식",
+ "exportFormats": {
+ "wav": "오디오 (WAV)",
+ "mp3": "오디오 (MP3)",
+ "m4b": "오디오북 (M4B, 챕터 포함)"
+ },
"empty": {
"title": "이 스토리에 항목이 없습니다",
"hint": "아래 상자를 사용하여 음성을 생성하고 항목을 추가하세요"
@@ -650,6 +656,7 @@
"menu": "작업",
"play": "재생",
"exportAudio": "오디오 내보내기",
+ "exportAudioMp3": "오디오 내보내기 (MP3)",
"exportPackage": "패키지 내보내기",
"applyEffects": "효과 적용",
"regenerate": "다시 생성"
@@ -760,8 +767,13 @@
}
},
"general": {
- "docs": { "title": "문서 읽기" },
- "discord": { "title": "Discord 참여하기", "subtitle": "도움말 & 음성 공유" },
+ "docs": {
+ "title": "문서 읽기"
+ },
+ "discord": {
+ "title": "Discord 참여하기",
+ "subtitle": "도움말 & 음성 공유"
+ },
"serverUrl": {
"title": "서버 URL",
"description": "voicebox 백엔드 서버 주소입니다.",
diff --git a/app/src/i18n/locales/pt-BR/translation.json b/app/src/i18n/locales/pt-BR/translation.json
index 08975f28..a51ff59c 100644
--- a/app/src/i18n/locales/pt-BR/translation.json
+++ b/app/src/i18n/locales/pt-BR/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "Nenhuma geração correspondente encontrada",
"searchNoAvailable": "Nenhuma geração disponível",
"exportAudio": "Exportar Áudio",
+ "exportDropdownLabel": "Exportar história como",
+ "exportFormats": {
+ "wav": "Áudio (WAV)",
+ "mp3": "Áudio (MP3)",
+ "m4b": "Audiolivro (M4B, capítulos)"
+ },
"empty": {
"title": "Nenhum item nesta história",
"hint": "Gere fala usando a caixa abaixo para adicionar itens"
@@ -650,6 +656,7 @@
"menu": "Ações",
"play": "Reproduzir",
"exportAudio": "Exportar Áudio",
+ "exportAudioMp3": "Exportar Áudio (MP3)",
"exportPackage": "Exportar Pacote",
"applyEffects": "Aplicar Efeitos",
"regenerate": "Regenerar"
@@ -760,8 +767,13 @@
}
},
"general": {
- "docs": { "title": "Ler a Documentação" },
- "discord": { "title": "Entrar no Discord", "subtitle": "Tire dúvidas e compartilhe vozes" },
+ "docs": {
+ "title": "Ler a Documentação"
+ },
+ "discord": {
+ "title": "Entrar no Discord",
+ "subtitle": "Tire dúvidas e compartilhe vozes"
+ },
"serverUrl": {
"title": "URL do Servidor",
"description": "O endereço do seu servidor backend do Voicebox.",
diff --git a/app/src/i18n/locales/zh-CN/translation.json b/app/src/i18n/locales/zh-CN/translation.json
index ff827a0c..1b651bd4 100644
--- a/app/src/i18n/locales/zh-CN/translation.json
+++ b/app/src/i18n/locales/zh-CN/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "未找到匹配的生成",
"searchNoAvailable": "暂无可用的生成",
"exportAudio": "导出音频",
+ "exportDropdownLabel": "导出故事为",
+ "exportFormats": {
+ "wav": "音频 (WAV)",
+ "mp3": "音频 (MP3)",
+ "m4b": "有声书 (M4B,含章节)"
+ },
"empty": {
"title": "此故事暂无项目",
"hint": "使用下方输入框生成语音以添加项目"
@@ -650,6 +656,7 @@
"menu": "操作",
"play": "播放",
"exportAudio": "导出音频",
+ "exportAudioMp3": "导出音频 (MP3)",
"exportPackage": "导出包",
"applyEffects": "应用效果",
"regenerate": "重新生成"
@@ -760,8 +767,13 @@
}
},
"general": {
- "docs": { "title": "阅读文档" },
- "discord": { "title": "加入 Discord", "subtitle": "获取帮助 & 分享声音" },
+ "docs": {
+ "title": "阅读文档"
+ },
+ "discord": {
+ "title": "加入 Discord",
+ "subtitle": "获取帮助 & 分享声音"
+ },
"serverUrl": {
"title": "服务器 URL",
"description": "Voicebox 后端服务器的地址。",
diff --git a/app/src/i18n/locales/zh-TW/translation.json b/app/src/i18n/locales/zh-TW/translation.json
index ed1e6bbb..0d8038d1 100644
--- a/app/src/i18n/locales/zh-TW/translation.json
+++ b/app/src/i18n/locales/zh-TW/translation.json
@@ -623,6 +623,12 @@
"searchNoMatches": "找不到相符的生成",
"searchNoAvailable": "尚無可用的生成",
"exportAudio": "匯出音訊",
+ "exportDropdownLabel": "匯出故事為",
+ "exportFormats": {
+ "wav": "音訊 (WAV)",
+ "mp3": "音訊 (MP3)",
+ "m4b": "有聲書 (M4B,含章節)"
+ },
"empty": {
"title": "此故事尚無項目",
"hint": "使用下方輸入框生成語音以新增項目"
@@ -650,6 +656,7 @@
"menu": "操作",
"play": "播放",
"exportAudio": "匯出音訊",
+ "exportAudioMp3": "匯出音訊 (MP3)",
"exportPackage": "匯出套件",
"applyEffects": "套用效果",
"regenerate": "重新生成"
@@ -760,8 +767,13 @@
}
},
"general": {
- "docs": { "title": "閱讀文件" },
- "discord": { "title": "加入 Discord", "subtitle": "取得協助與分享聲音" },
+ "docs": {
+ "title": "閱讀文件"
+ },
+ "discord": {
+ "title": "加入 Discord",
+ "subtitle": "取得協助與分享聲音"
+ },
"serverUrl": {
"title": "伺服器 URL",
"description": "Voicebox 後端伺服器的位址。",
diff --git a/app/src/lib/api/client.ts b/app/src/lib/api/client.ts
index f89a17a3..5eed5425 100644
--- a/app/src/lib/api/client.ts
+++ b/app/src/lib/api/client.ts
@@ -8,6 +8,7 @@ import type {
EffectConfig,
EffectPresetCreate,
EffectPresetResponse,
+ GenerationExportFormat,
GenerationRequest,
GenerationResponse,
GenerationVersionResponse,
@@ -25,6 +26,7 @@ import type {
StoryDetailResponse,
StoryItemBatchUpdate,
StoryItemCreate,
+ StoryExportFormat,
StoryItemDetail,
StoryItemMove,
StoryItemReorder,
@@ -340,8 +342,11 @@ class ApiClient {
return response.blob();
}
- async exportGenerationAudio(generationId: string): Promise<Blob> {
- const url = `${this.getBaseUrl()}/history/${generationId}/export-audio`;
+ async exportGenerationAudio(
+ generationId: string,
+ format: GenerationExportFormat = 'wav',
+ ): Promise<Blob> {
+ const url = `${this.getBaseUrl()}/history/${generationId}/export-audio?format=${format}`;
const response = await fetch(url);
if (!response.ok) {
@@ -830,8 +835,10 @@ class ApiClient {
});
}
- async exportStoryAudio(storyId: string): Promise<Blob> {
- const url = `${this.getBaseUrl()}/stories/${storyId}/export-audio`;
+ async exportStoryAudio(storyId: string, format: StoryExportFormat = 'wav'): Promise<Blob> {
+ const params = new URLSearchParams({ format });
+ if (format === 'm4b') params.set('chapters', 'auto');
+ const url = `${this.getBaseUrl()}/stories/${storyId}/export-audio?${params}`;
const response = await fetch(url);
if (!response.ok) {
diff --git a/app/src/lib/api/types.ts b/app/src/lib/api/types.ts
index 536d14aa..478d0ba9 100644
--- a/app/src/lib/api/types.ts
+++ b/app/src/lib/api/types.ts
@@ -419,6 +419,9 @@ export interface StoryResponse {
item_count: number;
}
+export type GenerationExportFormat = 'wav' | 'mp3';
+export type StoryExportFormat = 'wav' | 'mp3' | 'm4b';
+
export interface StoryItemDetail {
id: string;
story_id: string;
diff --git a/app/src/lib/hooks/useHistory.ts b/app/src/lib/hooks/useHistory.ts
index 51983339..f9c30fdc 100644
--- a/app/src/lib/hooks/useHistory.ts
+++ b/app/src/lib/hooks/useHistory.ts
@@ -1,6 +1,6 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { apiClient } from '@/lib/api/client';
-import type { HistoryQuery } from '@/lib/api/types';
+import type { GenerationExportFormat, HistoryQuery } from '@/lib/api/types';
import { usePlatform } from '@/platform/PlatformContext';
export function useHistory(query?: HistoryQuery) {
@@ -72,8 +72,16 @@ export function useExportGenerationAudio() {
const platform = usePlatform();
return useMutation({
- mutationFn: async ({ generationId, text }: { generationId: string; text: string }) => {
- const blob = await apiClient.exportGenerationAudio(generationId);
+ mutationFn: async ({
+ generationId,
+ text,
+ format = 'wav',
+ }: {
+ generationId: string;
+ text: string;
+ format?: GenerationExportFormat;
+ }) => {
+ const blob = await apiClient.exportGenerationAudio(generationId, format);
// Create safe filename from text. Append a short id so exports of
// similarly-worded generations don't collide on the same filename
@@ -82,12 +90,12 @@ export function useExportGenerationAudio() {
.substring(0, 30)
.replace(/[^a-z0-9]/gi, '-')
.toLowerCase();
- const filename = `${safeText}-${generationId.substring(0, 8)}.wav`;
+ const filename = `${safeText}-${generationId.substring(0, 8)}.${format}`;
await platform.filesystem.saveFile(filename, blob, [
{
name: 'Audio File',
- extensions: ['wav'],
+ extensions: [format],
},
]);
diff --git a/app/src/lib/hooks/useStories.ts b/app/src/lib/hooks/useStories.ts
index 7c7eae6c..3593c8f9 100644
--- a/app/src/lib/hooks/useStories.ts
+++ b/app/src/lib/hooks/useStories.ts
@@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { apiClient } from '@/lib/api/client';
import type {
StoryCreate,
+ StoryExportFormat,
StoryItemBatchUpdate,
StoryItemCreate,
StoryItemMove,
@@ -232,20 +233,28 @@ export function useExportStoryAudio() {
const platform = usePlatform();
return useMutation({
- mutationFn: async ({ storyId, storyName }: { storyId: string; storyName: string }) => {
- const blob = await apiClient.exportStoryAudio(storyId);
+ mutationFn: async ({
+ storyId,
+ storyName,
+ format = 'wav',
+ }: {
+ storyId: string;
+ storyName: string;
+ format?: StoryExportFormat;
+ }) => {
+ const blob = await apiClient.exportStoryAudio(storyId, format);
// Create safe filename
const safeName = storyName
.substring(0, 50)
.replace(/[^a-z0-9]/gi, '-')
.toLowerCase();
- const filename = `${safeName || 'story'}.wav`;
+ const filename = `${safeName || 'story'}.${format}`;
await platform.filesystem.saveFile(filename, blob, [
{
name: 'Audio File',
- extensions: ['wav'],
+ extensions: [format],
},
]);