natrys / whisper.el

Speech-to-Text interface for Emacs using OpenAI's whisper model and whisper.cpp as inference engine.
140 stars 10 forks source link

read-only buffer #5

Closed oatmealm closed 10 months ago

oatmealm commented 1 year ago

I ran whisper-file while the active buffer was read-only, so it couldn't yank to transcription. I guess it'd be better to check and warn the user, or maybe simply create a new buffer? Also, since it's async, where will the text end up when done if you switched buffers in the meantime?

natrys commented 1 year ago

where will the text end up when done if you switched buffers in the meantime?

At the original point position of the original buffer, when whisper-run or whisper-file was called.

The position is stored as a marker object which not only stores point but also the buffer info. As an added benefit, the marker is a "live" object, meaning if the original buffer is updated, then the marker position is also automatically updated by Emacs, so the relative position of where you wanted to insert the text originally always remains consistent. I haven't tested that extensively though.

I ran whisper-file while the active buffer was read-only, so it couldn't yank to transcription.

Yeah that's another case I hadn't considered. I think a warning and early exit is the simplest and consistent thing to do as people expect text to be inserted at point, rather than in a new buffer. Maybe even a prompt about disabling read-only mode on user's behalf, though that's a little intrusive. I will implement at least the warning and early exit later, once I understand the tricks involved. Because iirc it's not just whole buffer that can be read-only, but also like some portions of the text in it (marked using text property).

oatmealm commented 1 year ago

My workflow is longer transcriptions I like to dump into a document and process later, so insert at point is less relevant, but I understand why it's the default.

natrys commented 10 months ago

Read only buffers are now checked for (and bailed out) in a pre-processing hook.

Inserting under point is now optional. If you want a new buffer to be displayed with transcribed text, set whisper-insert-text-at-point to nil.