Skip to content

Commit

Permalink
feat: transcribe immediately after download from URL
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Oct 15, 2024
1 parent cb0eba9 commit 276a6a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion desktop/src/pages/home/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function Home() {
)}
{vm.audio && !vm.loading && (
<>
<button onMouseDown={vm.transcribe} className="btn btn-primary mt-3">
<button onMouseDown={() => vm.transcribe(vm.files[0].path)} className="btn btn-primary mt-3">
{t('common.transcribe')}
</button>
<ModelOptions options={vm.preference.modelOptions} setOptions={vm.preference.setModelOptions} />
Expand Down
5 changes: 3 additions & 2 deletions desktop/src/pages/home/viewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ export function viewModel() {
emit('stop_record')
}

async function transcribe() {
async function transcribe(path: string) {
setSegments(null)
setLoading(true)
abortRef.current = false

try {
await invoke('load_model', { modelPath: preference.modelPath, gpuDevice: preference.gpuDevice })
const options = {
path: files[0].path,
path,
...preference.modelOptions,
}
const startTime = performance.now()
Expand Down Expand Up @@ -324,6 +324,7 @@ export function viewModel() {
const outPath = await ytDlp.downloadAudio(audioUrl, preference.storeRecordInDocuments)
preference.setHomeTabIndex(1)
setFiles([{ name: 'audio.m4a', path: outPath }])
transcribe(outPath)
} catch (e) {
console.error(e)
setErrorModal?.({ log: String(e), open: true })
Expand Down

0 comments on commit 276a6a2

Please sign in to comment.