Member-only story

How to show AI response and speak it out with AI sound engine in Emacs?

DAMON CHAN
2 min readJan 29, 2025

--

By using this tatic, generate the AI result and speak with AI at the same time…

If you’re using [paw.el](https://github.com/chenyanming/paw), the language learning and annotation tool for Emacs, integrating AI responses into your workflow becomes seamless. By using [gptel](https://github.com/karthink/gptel), you can easily display AI-generated responses in the `*paw-view-note*` buffer with functions like `paw-view-note` and `paw-new-entry`. Additionally, you can use Edge-TTS to vocalize the response, employ go-translate for translation, and further interact with or add the information to your database right from the `*paw-view-note*` buffer.

(defun gptel-quick (&optional query)
“ASK AI with predefined prompts, show it in paw-view-note buffer, and say it out!”
(interactive)
(require ‘gptel)
(let* ((selected-text (when (use-region-p)
(buffer-substring-no-properties (region-beginning) (region-end))))
;; (current-buffer-text (buffer-substring-no-properties (point-min) (point-max)))
(additional-text (or selected-text “”))
(prompt (completing-read “Ask AI: “
‘(“Draft an outline”
“Draft anything”
“Draft an email”
“Draft a journal entry”
“Draft a meeting agenda”
“Explain in 12 words or less”
“Explain in 48 words or less”
“Explain in 100 words or less”
“Explain in 200 words or less”
“Write anything”
“Brainstorm ideas”
“Translate it to Chinese”))))
(when (string= prompt “”) (user-error “A prompt is required.”))
(deactivate-mark)
(setq gptel-last-prompt…

--

--

DAMON CHAN
DAMON CHAN

Written by DAMON CHAN

I love Programming, writing, and sharing interesting ideas. I believe only the ideas that we actually live are of any value.

No responses yet