Skip to content

Commit

Permalink
feat: save summary in .summary.txt when batch summary
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Nov 14, 2024
1 parent 8244a16 commit c879cae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Binary file modified desktop/bun.lockb
Binary file not shown.
7 changes: 6 additions & 1 deletion desktop/src/pages/batch/viewModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ export function viewModel() {
let total = Math.round((performance.now() - startTime) / 1000)
console.info(`Transcribe ${file.name} took ${total} seconds.`)

let llmSegments: Segment[] | null = null
if (llm && preference.llmConfig?.enabled) {
try {
const question = `${preference.llmConfig.prompt.replace('%s', transcript.asText(res.segments))}`
const answer = await llm.ask(question)
if (answer) {
res.segments = [{ start: 0, stop: res.segments?.[res.segments?.length - 1].stop ?? 0, text: answer }]
llmSegments = [{ start: 0, stop: res.segments?.[res.segments?.length - 1].stop ?? 0, text: answer }]
}
} catch (e) {
toast.error(String(e))
Expand All @@ -166,6 +167,10 @@ export function viewModel() {
await fs.writeTextFile(dst, getText(res.segments, format))
}
}
if (llmSegments) {
const summaryPath = await invoke<string>('get_path_dst', { src: file.path, suffix: '.summary.txt' })
await fs.writeTextFile(summaryPath, getText(llmSegments, 'srt'))
}
localIndex += 1
await new Promise((resolve) => setTimeout(resolve, 100))
setCurrentIndex(localIndex)
Expand Down

0 comments on commit c879cae

Please sign in to comment.