diff --git a/desktop/src-tauri/locales/en-US/common.json b/desktop/src-tauri/locales/en-US/common.json index c07d748..f3f4ad4 100644 --- a/desktop/src-tauri/locales/en-US/common.json +++ b/desktop/src-tauri/locales/en-US/common.json @@ -38,6 +38,7 @@ "find-here": "Find Here", "focus-window-on-finish": "Focus window", "format": "Format", + "formats": "Formats", "general": "General", "gpu-device": "GPU Device number", "high-gpu-performance": "Set Graphics performance to high", diff --git a/desktop/src-tauri/locales/fr-FR/common.json b/desktop/src-tauri/locales/fr-FR/common.json index 4dc9822..982bd7f 100644 --- a/desktop/src-tauri/locales/fr-FR/common.json +++ b/desktop/src-tauri/locales/fr-FR/common.json @@ -38,6 +38,7 @@ "find-here": "Trouver ici", "focus-window-on-finish": "Mettre la fenêtre au premier plan", "format": "Format", + "formats": "Formats", "general": "Général", "gpu-device": "Numéro de périphérique GPU", "high-gpu-performance": "Définir les performances graphiques sur élevé", diff --git a/desktop/src-tauri/locales/he-IL/common.json b/desktop/src-tauri/locales/he-IL/common.json index a2743fd..a7c0b7e 100644 --- a/desktop/src-tauri/locales/he-IL/common.json +++ b/desktop/src-tauri/locales/he-IL/common.json @@ -38,6 +38,7 @@ "find-here": "מצא כאן", "focus-window-on-finish": "העבר חלון לחזית", "format": "פורמט", + "formats": "פורמטים", "general": "כללי", "gpu-device": "מספר התקן GPU", "high-gpu-performance": "הגדר את ביצועי הגרפיקה לגבוהים", diff --git a/desktop/src-tauri/locales/hi-IN/common.json b/desktop/src-tauri/locales/hi-IN/common.json index d7ed046..bb82717 100644 --- a/desktop/src-tauri/locales/hi-IN/common.json +++ b/desktop/src-tauri/locales/hi-IN/common.json @@ -38,6 +38,7 @@ "find-here": "यहां खोजें", "focus-window-on-finish": "विंडो पर ध्यान केंद्रित करें", "format": "स्वरूप", + "formats": "प्रारूप", "general": "सामान्य", "gpu-device": "GPU डिवाइस नंबर", "high-gpu-performance": "ग्राफिक्स प्रदर्शन को उच्च सेट करें", diff --git a/desktop/src-tauri/locales/it-IT/common.json b/desktop/src-tauri/locales/it-IT/common.json index 0ffd06e..4c058a0 100644 --- a/desktop/src-tauri/locales/it-IT/common.json +++ b/desktop/src-tauri/locales/it-IT/common.json @@ -38,6 +38,7 @@ "find-here": "Trova qui", "focus-window-on-finish": "Focus finestra", "format": "Formato", + "formats": "Formati", "general": "Generale", "gpu-device": "Numero GPU Device", "high-gpu-performance": "Imposta il livello delle performance grafiche su Alto", diff --git a/desktop/src-tauri/locales/pl-PL/common.json b/desktop/src-tauri/locales/pl-PL/common.json index 97fb9c1..5d0dcc7 100644 --- a/desktop/src-tauri/locales/pl-PL/common.json +++ b/desktop/src-tauri/locales/pl-PL/common.json @@ -38,6 +38,7 @@ "find-here": "Znajdź tutaj", "focus-window-on-finish": "Skupienie na oknie", "format": "format", + "formats": "Formaty", "general": "ogólny", "gpu-device": "Numer urządzenia GPU", "high-gpu-performance": "Ustaw wydajność grafiki na wysoką", diff --git a/desktop/src-tauri/locales/pt-BR/common.json b/desktop/src-tauri/locales/pt-BR/common.json index a03d251..1f1bc90 100644 --- a/desktop/src-tauri/locales/pt-BR/common.json +++ b/desktop/src-tauri/locales/pt-BR/common.json @@ -38,6 +38,7 @@ "find-here": "Encontre aqui", "focus-window-on-finish": "Focar janela ao terminar", "format": "Formatar", + "formats": "Formatos", "general": "Geral", "gpu-device": "Número do dispositivo GPU", "high-gpu-performance": "Defina o desempenho gráfico como alto", diff --git a/desktop/src-tauri/locales/sv-SE/common.json b/desktop/src-tauri/locales/sv-SE/common.json index c462045..938f886 100644 --- a/desktop/src-tauri/locales/sv-SE/common.json +++ b/desktop/src-tauri/locales/sv-SE/common.json @@ -38,6 +38,7 @@ "find-here": "Hitta här", "focus-window-on-finish": "Fokusera Vibe när transkibering är klar", "format": "Formatera", + "formats": "Format", "general": "Allmän", "gpu-device": "GPU-enhetsnummer", "high-gpu-performance": "Ställ in grafikprestanda på hög", diff --git a/desktop/src-tauri/locales/zh-CN/common.json b/desktop/src-tauri/locales/zh-CN/common.json index 8aee434..62c14f0 100644 --- a/desktop/src-tauri/locales/zh-CN/common.json +++ b/desktop/src-tauri/locales/zh-CN/common.json @@ -38,6 +38,7 @@ "find-here": "在这里找到", "focus-window-on-finish": "转录完成时切换到此应用窗口", "format": "格式", + "formats": "格式", "general": "通用", "gpu-device": "GPU 设备编号", "high-gpu-performance": "将图形性能设置为高", diff --git a/desktop/src/components/FormatMultiSelect.tsx b/desktop/src/components/FormatMultiSelect.tsx new file mode 100644 index 0000000..8aa5596 --- /dev/null +++ b/desktop/src/components/FormatMultiSelect.tsx @@ -0,0 +1,54 @@ +import { Dispatch, SetStateAction } from 'react' +import { useTranslation } from 'react-i18next' + +export type TextFormat = 'normal' | 'srt' | 'vtt' | 'html' | 'pdf' | 'json' | 'docx' +export type FormatExtensions = { + [name in TextFormat]: string +} +export const formatExtensions: FormatExtensions = { + normal: '.txt', + srt: '.srt', + vtt: '.vtt', + html: '.html', + pdf: '.pdf', + json: '.json', + docx: '.docx', +} + +interface FormatMultiSelectProps { + formats: TextFormat[] + setFormats: Dispatch> +} +export default function FormatMultiSelect({ formats, setFormats }: FormatMultiSelectProps) { + const { t } = useTranslation() + + const handleFormatButtonClick = (formatOption: TextFormat) => { + // Check if the format is already selected + if (formats.includes(formatOption)) { + // If it's selected, remove it + setFormats(formats.filter((format) => format !== formatOption)) + } else { + // If it's not selected, add it to the array + setFormats([...formats, formatOption]) + } + } + + return ( + + ) +} diff --git a/desktop/src/pages/batch/Page.tsx b/desktop/src/pages/batch/Page.tsx index 6a58987..a991f22 100644 --- a/desktop/src/pages/batch/Page.tsx +++ b/desktop/src/pages/batch/Page.tsx @@ -1,11 +1,11 @@ import { useTranslation } from 'react-i18next' -import FormatSelect from '~/components/FormatSelect' import LanguageInput from '~/components/LanguageInput' import Layout from '~/components/Layout' import ModelOptions from '~/components/Params' import BatchPanel from './BatchPanel' import { viewModel } from './viewModel' import { cx } from '~/lib/utils' +import FormatMultiSelect from '~/components/FormatMultiSelect' export default function BatchPage() { const vm = viewModel() @@ -16,7 +16,7 @@ export default function BatchPage() {
- +
diff --git a/desktop/src/pages/batch/viewModel.tsx b/desktop/src/pages/batch/viewModel.tsx index 68521c1..6d79baf 100644 --- a/desktop/src/pages/batch/viewModel.tsx +++ b/desktop/src/pages/batch/viewModel.tsx @@ -22,7 +22,7 @@ import toast from 'react-hot-toast' export function viewModel() { const { files, setFiles } = useFilesContext() - const [format, setFormat] = useState('normal') + const [formats, setFormats] = useState(['normal']) const [currentIndex, setCurrentIndex] = useState(0) const [progress, setProgress] = useState(null) const [inProgress, setInProgress] = useState(false) @@ -153,18 +153,19 @@ export function viewModel() { } } - const dst = await invoke('get_path_dst', { src: file.path, suffix: formatExtensions[format] }) - // Write file - if (format === 'docx') { - const fileName = await path.basename(dst) - const doc = await toDocx(fileName, res.segments, preference.textAreaDirection) - const arrayBuffer = await doc.arrayBuffer() - const buffer = new Uint8Array(arrayBuffer) - fs.writeFile(dst, buffer) - } else { - await fs.writeTextFile(dst, getText(res.segments, format)) + for (const format of formats) { + const dst = await invoke('get_path_dst', { src: file.path, suffix: formatExtensions[format] }) + // Write file + if (format === 'docx') { + const fileName = await path.basename(dst) + const doc = await toDocx(fileName, res.segments, preference.textAreaDirection) + const arrayBuffer = await doc.arrayBuffer() + const buffer = new Uint8Array(arrayBuffer) + fs.writeFile(dst, buffer) + } else { + await fs.writeTextFile(dst, getText(res.segments, format)) + } } - localIndex += 1 await new Promise((resolve) => setTimeout(resolve, 100)) setCurrentIndex(localIndex) @@ -230,8 +231,8 @@ export function viewModel() { cancel, start, files, - format, - setFormat, + formats, + setFormats, preference: preference, } }