johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
5.26k stars 256 forks source link

Use piper for TTS rendering #1275

Closed sati-bodhi closed 3 months ago

sati-bodhi commented 3 months ago

There's a Narration button (the one with a headphones icon) on the navbar (which is available by hovering or tapping on the footer area).

Note that if the book has embedded audio (media overlays), the Narration button would show controls for the embedded media, and TTS would not be available in that case.

Alternatively you can select some text and choose Speak from here from the selection menu. Though you still need to use the Narration button if you want to stop the speech output.

Originally posted by @johnfactotum in https://github.com/johnfactotum/foliate/discussions/1200#discussioncomment-8009184

I've installed pied and speech-dispatcher seems to be working with spd-say - even though there is this error:

speech-dispatcher
[Thu Mar 21 18:26:17 2024 : 529864] speechd: Speech Dispatcher 0.11.1 starting
[Thu Mar 21 18:26:17 2024 : 530027] speechd:  Configuration has been read from "/home/sati/.config/speech-dispatcher/speechd.conf"
[Thu Mar 21 18:26:17 2024 : 530055] speechd:  Initializing output module piper with binary /usr/lib/speech-dispatcher-modules/sd_generic and configuration /home/sati/.config/speech-dispatcher/modules/piper.conf
[Thu Mar 21 18:26:17 2024 : 530065] speechd:   Output module is logging to file /run/user/1000/speech-dispatcher/log//piper.log
[Thu Mar 21 18:26:17 2024 : 530480] speechd:  Module piper loaded.
[Thu Mar 21 18:26:17 2024 : 531893] speechd:  Module piper started successfully with message: 
---------------
Everything ok so far.
---------------

[Thu Mar 21 18:26:17 2024 : 532387] speechd:  Error: Module reported error in request from speechd (code 3xx): 300-Opening sound device failed. Reason: Cannot open plugin server. error: file not found. 
300 MODULE ERROR
.
[Thu Mar 21 18:26:17 2024 : 619994] speechd: LINE here:|200-Piper   en-us   FEMALE1|
[Thu Mar 21 18:26:17 2024 : 620033] speechd: LINE here:|200 OK VOICE LIST SENT|

When I run narration, I get a TTS error:

image

Any idea how to fix this?

johnfactotum commented 3 months ago

It would print the error code and message to the console. It's probably throwing at the 300 MODULE ERROR message.

sati-bodhi commented 3 months ago

Here are the issues stated when running on terminal.

$ foliate
/usr/share/libdrm/amdgpu.ids: No such file or directory
/usr/share/libdrm/amdgpu.ids: No such file or directory

(com.github.johnfactotum.Foliate:7197): Gtk-WARNING **: 21:32:30.479: No IM module matching GTK_IM_MODULE=fcitx found

(com.github.johnfactotum.Foliate:7197): com.github.johnfactotum.Foliate-WARNING **: 21:32:34.082: Error: Requiring Tracker, version none: Typelib file for namespace 'Tracker' (any version) not found
getURIFromTracker@resource:///com/github/johnfactotum/Foliate/library.js:83:24
get@resource:///com/github/johnfactotum/Foliate/library.js:121:42
getBookFromIdentifier@resource:///com/github/johnfactotum/Foliate/library.js:169:36
getBook@resource:///com/github/johnfactotum/Foliate/library.js:166:21
activate@resource:///com/github/johnfactotum/Foliate/library.js:860:63
activate@resource:///com/github/johnfactotum/Foliate/library.js:386:18
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

** (com.github.johnfactotum.Foliate:7197): WARNING **: 21:32:34.091: Could not open /sys/class/dmi/id/chassis_type: Failed to open file “/sys/class/dmi/id/chassis_type”: Permission denied

** (com.github.johnfactotum.Foliate:7197): WARNING **: 21:32:34.091: Could not open /sys/firmware/acpi/pm_profile: Failed to open file “/sys/firmware/acpi/pm_profile”: Permission denied
/usr/share/libdrm/amdgpu.ids: No such file or directory

(process:7369): GLib-GIO-WARNING **: 21:32:34.407: GDBus.Error:org.freedesktop.portal.Error.NotAllowed: This call is not available inside the sandbox
/usr/share/libdrm/amdgpu.ids: No such file or directory

** (process:7372): WARNING **: 21:32:34.692: Could not open /sys/class/dmi/id/chassis_type: Failed to open file “/sys/class/dmi/id/chassis_type”: Permission denied

** (process:7372): WARNING **: 21:32:34.692: Could not open /sys/firmware/acpi/pm_profile: Failed to open file “/sys/firmware/acpi/pm_profile”: Permission denied

** (process:7372): WARNING **: 21:32:34.693: Failed to get atspi registered event listeners: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.48" (uid=1000 pid=7372 comm="/usr/lib/x86_64-linux-gnu/webkitgtk-6.0/WebKitWebP" label="snap.foliate.foliate (enforce)") interface="org.a11y.atspi.Registry" member="GetRegisteredEvents" error name="(unset)" requested_reply="0" destination=":1.4" (uid=1000 pid=3039 comm="/usr/libexec/at-spi2-registryd --use-gnome-session" label="unconfined")

(com.github.johnfactotum.Foliate:7197): com.github.johnfactotum.Foliate-CRITICAL **: 21:32:39.550: Error: Error connecting to /run/user/1000/speech-dispatcher/speechd.sock: Gio.IOErrorEnum: Could not connect: Connection refused
connect@resource:///com/github/johnfactotum/Foliate/speech.js:28:19
init@resource:///com/github/johnfactotum/Foliate/speech.js:83:30
send@resource:///com/github/johnfactotum/Foliate/speech.js:114:20
stop@resource:///com/github/johnfactotum/Foliate/speech.js:146:21
#init@resource:///com/github/johnfactotum/Foliate/tts.js:64:21
start@resource:///com/github/johnfactotum/Foliate/tts.js:86:19
play@resource:///com/github/johnfactotum/Foliate/tts.js:82:45
addMethods/</<@resource:///com/github/johnfactotum/Foliate/utils.js:281:58
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34
sati-bodhi commented 3 months ago

Catalogs don't work for me too.

johnfactotum commented 3 months ago

Could not connect: Connection refused

See #1126