aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2022-01-01 05:11:17 +0100
committerGitHub <noreply@github.com>2022-01-01 11:11:17 +0700
commita6a03cf77fa8a925ecd18c840c8a8f358e207fcc (patch)
tree189a664eec647df5f701b072ed466b8d966e56b1
parent20df9c527b543aeef905c53550e5da44ee8c203f (diff)
downloadepy-a6a03cf77fa8a925ecd18c840c8a8f358e207fcc.tar.gz
Use mimic instead of pico2wave. (#44)
-rw-r--r--README.md10
-rwxr-xr-xepy.py22
2 files changed, 13 insertions, 19 deletions
diff --git a/README.md b/README.md
index d434d79..a3950c3 100644
--- a/README.md
+++ b/README.md
@@ -87,21 +87,19 @@ But you can enable it by setting `MouseSupport` to `true` in config file.
To get Text-to-Speech (TTS) support, you need to install these external dependencies:
-- `pico2wave` (from `libttspico-utils` package (Ubuntu) or `svox-pico-bin` package (AUR))
-- `play` (from `sox` package)
+- `mimic` package (AUR))
eg.
```shell
$ # Ubuntu
-$ apt install libttspico-utils sox
+$ apt install mimic
$ # Arch
-$ yay -S svox-pico-bin
-$ pacman -S sox
+$ pacman -S mimic
```
-And then make sure `pico2wave` and `play` is in `$PATH`.
+And then make sure `mimic` is in `$PATH`.
## Double Spread
diff --git a/epy.py b/epy.py
index 6b131b7..6c9510b 100755
--- a/epy.py
+++ b/epy.py
@@ -1881,7 +1881,7 @@ class Reader:
self.jump_list: Mapping[str, ReadingState] = dict()
# TTS speaker utils
- self._tts_support: bool = any([shutil.which("pico2wave"), shutil.which("play")])
+ self._tts_support: bool = any([shutil.which("mimic")])
self.is_speaking: bool = False
# multi process & progress percentage
@@ -2344,19 +2344,16 @@ class Reader:
self.screen.refresh()
self.screen.timeout(1)
try:
- _, path = tempfile.mkstemp(suffix=".wav")
- subprocess.call(
- ["pico2wave", f"--lang={self.setting.TTSLang}", "-w", path, text],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- )
- speaker = subprocess.Popen(
- ["play", path, "tempo", str(self.setting.TTSSpeed)],
+ spk = subprocess.Popen(
+ ["mimic"], text=True,
+ stdin=subprocess.PIPE,
stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
+ stderr=subprocess.STDOUT,
)
+ spk.stdin.write(text)
+ spk.stdin.close()
while True:
- if speaker.poll() is not None:
+ if spk.poll() is not None:
k = self.keymap.PageDown[0]
break
tmp = self.screen.getch()
@@ -2383,12 +2380,11 @@ class Reader:
+ self.keymap.ScrollDown
+ (curses.KEY_RESIZE,)
):
- speaker.terminate()
+ spk.terminate()
# speaker.kill()
break
finally:
self.screen.timeout(-1)
- os.remove(path)
if k in self.keymap.Quit:
self.is_speaking = False