Created
February 24, 2025 15:59
-
-
Save glallen01/c0c9f1859c40a948a04b5445e1b36f45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; call `M-x whisper-run` to start recording, do it again to stop recording, transcribe, send to gptel for code-generation | |
;; must run `M-x gptel` to load all it's functions before calling `M-x whisper-run` | |
(use-package gptel | |
:custom ((gptel-api-key | |
(lambda () | |
(auth-source-pick-first-password :host "api.openai.com"))))) | |
(use-package whisper | |
:ensure (whisper :type git :host github :repo "natrys/whisper.el" :files ("whisper.el")) | |
:bind ("C-H-r" . whisper-run) | |
:config | |
(setq | |
whisper-install-whispercpp nil | |
whisper-model "large-v3-turbo-q5_0" | |
whisper-language "en" | |
whisper-translate nil | |
whisper--ffmpeg-input-device ":0" | |
whisper-use-threads (/ (num-processors) 2))) | |
;; brew install whisper-cpp | |
;; cd .emacs.d/.cache | |
;; curl -LO https://github.com/ggerganov/whisper.cpp/raw/refs/heads/master/models/download-ggml-model.sh | |
;; bash ./download-ggml-model.sh large-v3-turbo-q5_0 | |
(defun whisper--brew-command (input-file) | |
`("whisper-cpp" | |
"--model" ,(expand-file-name (concat "~/.emacs.d/.cache/" "ggml-" whisper-model ".bin")) | |
,@(when whisper-use-threads (list "--threads" (number-to-string whisper-use-threads))) | |
,@(when whisper-translate '("--translate")) | |
,@(when whisper-show-progress-in-mode-line '("--print-progress")) | |
"--language" ,whisper-language | |
"--no-timestamps" | |
"--file" ,input-file)) | |
(advice-add 'whisper-command :override #'whisper--brew-command) | |
(defun my/vibecoder--pipe-whisper-to-gptel-and-insert () | |
(let* ((transcription (buffer-substring-no-properties (point-min) (point-max))) | |
(system-message | |
"You are an experienced and careful programmer. Provide code and only code without markdown as output without any additional text, prompt, or notes.") | |
(original-buffer (other-buffer (current-buffer) t))) | |
(gptel-request transcription | |
:system system-message | |
:callback (lambda (response info) | |
(when (buffer-live-p original-buffer) | |
(with-current-buffer original-buffer | |
(insert response) | |
(insert "\n") | |
(comment-region (line-beginning-position) (line-end-position)))))))) | |
(add-hook 'whisper-after-transcription-hook | |
#'my/vibecoder--pipe-whisper-to-gptel-and-insert) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment