From 439e0439bd3d8b12082d2a6b30737db10c601166cfed3265d48dd0ff9beb6be9 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 17 Dec 2021 10:14:47 +0000 Subject: [PATCH 1/4] - Add tts_lang.patch to allow setting language of TTS (gh#wustho/epy#43). OBS-URL: https://build.opensuse.org/package/show/Education/epy?expand=0&rev=5 --- epy.changes | 21 +++++++++++++++++++++ epy.spec | 3 +++ tts_lang.patch | 21 +++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 tts_lang.patch diff --git a/epy.changes b/epy.changes index 4719c2d..301c29f 100644 --- a/epy.changes +++ b/epy.changes @@ -1,3 +1,24 @@ +------------------------------------------------------------------- +Fri Dec 17 10:13:56 UTC 2021 - Matej Cepl + +- Add tts_lang.patch to allow setting language of TTS + (gh#wustho/epy#43). + +------------------------------------------------------------------- +Sat Nov 27 10:19:32 UTC 2021 - mcepl@cepl.eu + +- Update to version 2021.10.23+git.1636702550.2ab1584: + * Fixed reset to beginning of row when resizing term and Seamless==True + * Implement SeamlessBetweenChapters Squashed commit of the following: + * Minor annotation & prevent next page animation on edge of book + * Removed Board class + * Added TextStructure dataclass + * Give styling to images + * Better image opening scheme + * Refactor parser.get_lines(width) to get_lines(textwidth) + * Fixed image cursor on double spread and progress pctg in double spread + * Refactor variables + ------------------------------------------------------------------- Wed Jul 28 23:20:26 UTC 2021 - Emily Roberts diff --git a/epy.spec b/epy.spec index adca717..2ac9691 100644 --- a/epy.spec +++ b/epy.spec @@ -24,6 +24,9 @@ License: GPL-3.0-only URL: https://github.com/wustho/epy # Source: https://files.pythonhosted.org/packages/source/e/epy-reader/epy-reader-%%{version}.tar.gz#/epy-%%{version}.tar.gz Source: epy-%{version}.tar.gz +# PATCH-FIX-UPSTREAM tts_lang.patch gh#wustho/epy#43 mcepl@suse.com +# Allow setting language of TTS engine. +Patch0: tts_lang.patch BuildRequires: fdupes BuildRequires: python3-mobi BuildRequires: python3-setuptools diff --git a/tts_lang.patch b/tts_lang.patch new file mode 100644 index 0000000..7029434 --- /dev/null +++ b/tts_lang.patch @@ -0,0 +1,21 @@ +diff --git a/epy.py b/epy.py +index 11eca60..d4ea184 100755 +--- a/epy.py ++++ b/epy.py +@@ -195,6 +195,7 @@ class Settings: + MouseSupport: bool = False + StartWithDoubleSpread: bool = False + TTSSpeed: int = 1 ++ TTSLang: str = "en-US" + # -1 is default terminal fg/bg colors + DarkColorFG: int = 252 + DarkColorBG: int = 235 +@@ -2336,7 +2337,7 @@ class Reader: + try: + _, path = tempfile.mkstemp(suffix=".wav") + subprocess.call( +- ["pico2wave", "-w", path, text], ++ ["pico2wave", f"--lang={self.setting.TTSLang}", "-w", path, text], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) From fba5bd228ff29b8b2d55f3ece70118361c09982fcd42b4d79de18f28bb4f609e Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 20 Dec 2021 19:40:25 +0000 Subject: [PATCH 2/4] - Replace tts_lang.patch with mimic.patch, switching the TTS engine to free mimic (svox is non-free), and allowing inclusion into openSUSE. OBS-URL: https://build.opensuse.org/package/show/Education/epy?expand=0&rev=6 --- epy.changes | 6 ++++++ epy.spec | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/epy.changes b/epy.changes index 301c29f..dd4d897 100644 --- a/epy.changes +++ b/epy.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Dec 20 19:39:29 UTC 2021 - Matej Cepl + +- Replace tts_lang.patch with mimic.patch, switching the TTS engine to + free mimic (svox is non-free), and allowing inclusion into openSUSE. + ------------------------------------------------------------------- Fri Dec 17 10:13:56 UTC 2021 - Matej Cepl diff --git a/epy.spec b/epy.spec index 2ac9691..6bd5387 100644 --- a/epy.spec +++ b/epy.spec @@ -24,15 +24,16 @@ License: GPL-3.0-only URL: https://github.com/wustho/epy # Source: https://files.pythonhosted.org/packages/source/e/epy-reader/epy-reader-%%{version}.tar.gz#/epy-%%{version}.tar.gz Source: epy-%{version}.tar.gz -# PATCH-FIX-UPSTREAM tts_lang.patch gh#wustho/epy#43 mcepl@suse.com -# Allow setting language of TTS engine. -Patch0: tts_lang.patch +# PATCH-FIX-UPSTREAM mimic.patch gh#wustho/epy#42 mcepl@suse.com +# Use mimic instead of non-free svox. +Patch0: mimic.patch BuildRequires: fdupes BuildRequires: python3-mobi BuildRequires: python3-setuptools Requires: python3-mobi Suggests: sdcv Suggests: dictd +Suggests: mimic BuildArch: noarch %description From de49d8830d5e335cf2dd4c3015d29e796945d7d045b1c02740ce175611a203ac Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 20 Dec 2021 19:44:56 +0000 Subject: [PATCH 3/4] Add the patch OBS-URL: https://build.opensuse.org/package/show/Education/epy?expand=0&rev=7 --- mimic.patch | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ tts_lang.patch | 21 ----------- 2 files changed, 100 insertions(+), 21 deletions(-) create mode 100644 mimic.patch delete mode 100644 tts_lang.patch diff --git a/mimic.patch b/mimic.patch new file mode 100644 index 0000000..eeef537 --- /dev/null +++ b/mimic.patch @@ -0,0 +1,100 @@ +From 30596836fcd707098bbae6ebe453e67eb2caef87 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= +Date: Mon, 20 Dec 2021 19:50:30 +0100 +Subject: [PATCH] Use mimic instead of pico2wave. + +Unfortunately, the language setting is gone again. + +Fixes #42 +--- + README.md | 10 ++++------ + epy.py | 22 +++++++++------------- + 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], ++ spk = subprocess.Popen( ++ ["mimic"], text=True, ++ stdin=subprocess.PIPE, + stdout=subprocess.DEVNULL, +- stderr=subprocess.DEVNULL, +- ) +- speaker = subprocess.Popen( +- ["play", path, "tempo", str(self.setting.TTSSpeed)], +- 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 +-- +2.34.1 + diff --git a/tts_lang.patch b/tts_lang.patch deleted file mode 100644 index 7029434..0000000 --- a/tts_lang.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/epy.py b/epy.py -index 11eca60..d4ea184 100755 ---- a/epy.py -+++ b/epy.py -@@ -195,6 +195,7 @@ class Settings: - MouseSupport: bool = False - StartWithDoubleSpread: bool = False - TTSSpeed: int = 1 -+ TTSLang: str = "en-US" - # -1 is default terminal fg/bg colors - DarkColorFG: int = 252 - DarkColorBG: int = 235 -@@ -2336,7 +2337,7 @@ class Reader: - try: - _, path = tempfile.mkstemp(suffix=".wav") - subprocess.call( -- ["pico2wave", "-w", path, text], -+ ["pico2wave", f"--lang={self.setting.TTSLang}", "-w", path, text], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - ) From e1a078109f083be5a0fbc576ba23a2fb76698a3d90315b91bbdbcca292b0fa15 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 20 Dec 2021 19:48:12 +0000 Subject: [PATCH 4/4] Adjust the patch OBS-URL: https://build.opensuse.org/package/show/Education/epy?expand=0&rev=8 --- mimic.patch | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/mimic.patch b/mimic.patch index eeef537..8917dcb 100644 --- a/mimic.patch +++ b/mimic.patch @@ -7,15 +7,13 @@ Unfortunately, the language setting is gone again. Fixes #42 --- - README.md | 10 ++++------ - epy.py | 22 +++++++++------------- + README.md | 10 ++++------ + epy.py | 22 +++++++++------------- 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. +@@ -93,21 +93,19 @@ But you can enable it by setting `MouseS To get Text-to-Speech (TTS) support, you need to install these external dependencies: @@ -41,11 +39,9 @@ index d434d79..a3950c3 100644 ## 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: +@@ -1871,7 +1871,7 @@ class Reader: self.jump_list: Mapping[str, ReadingState] = dict() # TTS speaker utils @@ -54,22 +50,22 @@ index 6b131b7..6c9510b 100755 self.is_speaking: bool = False # multi process & progress percentage -@@ -2344,19 +2344,16 @@ class Reader: +@@ -2334,19 +2334,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], -+ spk = subprocess.Popen( -+ ["mimic"], text=True, -+ stdin=subprocess.PIPE, - stdout=subprocess.DEVNULL, +- ["pico2wave", "-w", path, text], +- stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - ) - speaker = subprocess.Popen( - ["play", path, "tempo", str(self.setting.TTSSpeed)], -- stdout=subprocess.DEVNULL, ++ spk = subprocess.Popen( ++ ["mimic"], text=True, ++ stdin=subprocess.PIPE, + stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, + stderr=subprocess.STDOUT, ) @@ -81,7 +77,7 @@ index 6b131b7..6c9510b 100755 k = self.keymap.PageDown[0] break tmp = self.screen.getch() -@@ -2383,12 +2380,11 @@ class Reader: +@@ -2373,12 +2370,11 @@ class Reader: + self.keymap.ScrollDown + (curses.KEY_RESIZE,) ): @@ -95,6 +91,3 @@ index 6b131b7..6c9510b 100755 if k in self.keymap.Quit: self.is_speaking = False --- -2.34.1 -