djmango / obsidian-transcription

Obsidian plugin to create high-quality transcriptions from markdown linked audio files
https://swiftink.io
MIT License
156 stars 17 forks source link

Transcribe only selected media #12

Closed johannesCmayer closed 1 year ago

johannesCmayer commented 1 year ago

Hi, thank you very much for this, it generally works well for me right now. However, one problem that I am running into is that I can only every run the transcription once in a file. If I am running it twice, then all the already transcribed things will be transcribed again. That is kind of bad. It means that I need to create a separate file, where I put new recordings and transcribe them there, and then copy and paste the things. It would be nice if the transcription would only work on the current selection.

johannesCmayer commented 1 year ago

An alternative to this is to automatically insert some tokes like %%::transcribed::%% after the media that have already been transcribed, such that only media that do not have this token after them will be transcribed. This seems to me to be an even better solution.

djmango commented 1 year ago

I was working on this with context menus, but ran in to a roadblock. You can see what I was doing here, I think the feature is a great idea but would love some help on solving the problem.

johannesCmayer commented 1 year ago

How about this: Before you do get all the links in the current file, you check if the line the current cursor is on matches the regex ^!\[\[.*\]\]$. If it does, then don't get all the links in the current file and instead just use that link, and proceed with the rest of the code as is, e.g. next step is to check the extension and then throw an error.

If this is implemented the notification messages and logs should be adapted for this specific case, to only say that this specific file is transcribed. This seems to be a better and easier solution than implementing a right-click functionality.

johannesCmayer commented 1 year ago

Actually, another even better approach would be to change the logic when the file is written such that it appends a line %%TRANSCRIBED%% before the audiofile. E.g.:

![[some_media.mp3]]

turns into

%%TRANSCRIBED%%
![[some_media.mp3]]
TRANSCRIPTION_TEXT

Then instead of getting all file links with the inbuild functionality, you do a regex like ^!\[\[.*\]\]$ on each line, and filter the results based on if the previous line says %%TRANSCRIBED%%. The rest of the code should work the same.

johannesCmayer commented 1 year ago

I feel like this would be the best solution as you can just mindlessly run the transcription on the same file many times (as long as you don't schedule another transcription before the current one stops). In principle, you could then even create the functionality that media is transcribed as soon as it is added, simply by running the command automatically in the background each time that the file is modified (or you could be smart about it, but this dumb way would probably work quite well).

djmango commented 1 year ago

Completed in latest update!