Emacs 中的文本转语音

发布于 2024-08-16 18:26:52 字数 644 浏览 5 评论 0原文

我不是瞎子,我只是想有一种方法让我的 Windows 机器大声读取缓冲区的内容。以下是基本要求:

  • 读取任何英文文本缓冲区。
  • 随时暂停阅读并随时恢复(而不是当有人走进我的办公室时等待几分钟等待大缓冲区完成)。
  • 调整播放时的读回速度。
  • 突出显示当前正在阅读的文本(可选)

我发现了一些可能的解决方案:

  • Emacspeak:专为盲人设计。看起来像一个独立的程序,而不是 Emacs 插件
  • festival.el:需要节日。我找不到 Festival 的 Windows 二进制文件。有人有吗?
  • 我也可以自己写。如今,文本转语音 (TTS) 库非常多。交互式暂停功能可能是最大的技巧,但一定有一些库可以做到这一点。

哪个选项是最好的计划?我不想在这里进行为期一周的项目。在 Windows 中编译 Festival 是一个痛苦的实验。对于我想要的东西来说,Emacspeak 看起来有点矫枉过正。

I'm not blind, I just want to have a way to have my Windows machine read the contents of a buffer outloud. Here are the basic requirements:

  • Read any English text buffer.
  • Pause the reading at any time and resume at any time (not wait a few minutes for a big buffer to finish when someone walks into my office).
  • Adjust the read-back speed at play-time.
  • Highlight the text currently being read (optional)

I found a couple of possible solutions:

  • Emacspeak: Designed for the blind. Looks like a stand-alone program, not an Emacs plug-in
  • festival.el: Requires Festival. I can't find Windows Binaries for Festival. Anyone have them?
  • I could also write my own. Text-To-Speech (TTS) libraries are a plenty these days. The interactive pause feature may be the biggest trick, but there must be some libraries that can do it.

Which option is the best plan? I don't want a week-long project here. Compiling Festival in Windows has been a painful experiment. Emacspeak looks like overkill for what I want.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

看海 2024-08-23 18:26:52

适用于 Windows 的 Festival 可在此处获取。我不能保证 Festival.el 可以使用这些二进制文件。不过,我确实有使用这些二进制文件的经验,因此,如果您在使它们在 Emacs 之外工作时遇到问题,我也许可以提供帮助。

我不认为你可以控制节日的播放速度,尽管我可能是错的。至于保持对它的控制,我想说你最好的选择是对其进行编程,以便它一次只向节日发送一小部分。否则,确实没有任何方法可以阻止它在完成之前读取。

基本上,我认为没有任何东西可以在不做一些工作的情况下满足您的最低要求。

编辑:回顾您的要求后,我想说最好的方法是破解 Festival.el 一次向 Festival 发送一句话。然后你可以编写一个击键来杀死它,这样它就只会完成当前的句子。同时,您的脚本可以突出显示当前发送到 Festival 的句子。

Festival for Windows is available here. I can't guarantee that festival.el will work with these binaries. I do have experience working with these binaries, though, so if you have problems getting them to work outside of Emacs, I may be able to help.

I don't think you will have control over playback speed with festival, though I could be mistaken. As far as retaining control over it, I'd say your best bet is to program it so that it is only sending small portions at a time to festival. Otherwise, there really isn't any way to prevent it from reading until done.

Basically, I don't think that there is anything out there that would meet your minimum requirements without some work.

Edit: after looking back over your requirements, I'd say the best approach would be to hack festival.el to send a sentence at a time to Festival. Then you can program a keystroke that will kill it, so that it will only finish the current sentence. At the same time, your script could highlight the sentence that is currently being sent to Festival.

童话里做英雄 2024-08-23 18:26:52

我有一个基于 Python pyttsx 模块的简单解决方案。这将启动一个 python 脚本作为 emacs 进程并向其发送要读取的字符串。

(defvar tts nil "text to speech process")

(defun tts-up ()
  (interactive)
  (and (not (null tts))
       (eq (process-status tts) 'run)))

(defun tts-start ()
  (interactive)
  (if (not (tts-up))
      (setq tts
            (start-process "tts-python"
                           "*tts-python*"
                           "python" "speak.py"))))

(defun tts-end ()
  (interactive)
  (delete-process tts)
  (setq tts nil))

(defun tts-say (text)
  (interactive)
  (tts-start)
  (process-send-string tts (concat text "\n")))

python文件speak.py:

import pyttsx

engine = pyttsx.init()

def say(data):
    engine.say(data)
    engine.runAndWait()

while True:
    say(raw_input())

I have a simple solution based on the Python pyttsx module. This starts a python script as an emacs process and sends it strings to be read out.

(defvar tts nil "text to speech process")

(defun tts-up ()
  (interactive)
  (and (not (null tts))
       (eq (process-status tts) 'run)))

(defun tts-start ()
  (interactive)
  (if (not (tts-up))
      (setq tts
            (start-process "tts-python"
                           "*tts-python*"
                           "python" "speak.py"))))

(defun tts-end ()
  (interactive)
  (delete-process tts)
  (setq tts nil))

(defun tts-say (text)
  (interactive)
  (tts-start)
  (process-send-string tts (concat text "\n")))

The python file speak.py:

import pyttsx

engine = pyttsx.init()

def say(data):
    engine.say(data)
    engine.runAndWait()

while True:
    say(raw_input())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文