Contents

[Balabolka's Substitute] How I Use Reader View to Enjoy Microsoft Edge's Read Aloud in Linux

Abstract
TL;DR: I use Reader View to enjoy Microsoft Edge’s Read Aloud. I also found a way to read local html with it.

Introduction

Earlier this year I wrote Bimodal Reading in Balabolka, Microsoft Edge’s Read Aloud, and Audible’s Immersion Reading. For my brief introduction please see Microsoft Edge’s Read Aloud.

Ever since I switched to Linux, I’d been searching for a Balabolka substitute for a long time. The search was over for me. In terms of convenience, it was just as good as my old F7_SuperMemo_to_Balabolka.ahk, but Microsoft’s AI-generated voices is phenomenal. This guide is for Linux users who would like to do Bimodal Reading as convenient as possible.

Requirements

Note
I’m using sway but the idea is the same. Just change the program to set global shotcuts accordingly.
  1. ydotool

It’s a command-line automation tool. If you’re on Xorg, use xdotool.

  1. pandoc

We use pandoc to convert markdown to html.

  1. Microsoft Edge version 98.0.1108.62

The latest Edge version in Linux doesn’t have Read Aloud. Read Aloud is only available on version 98.0.1108.62. We need this exact version. If you’re on Arch Linux:

1
2
3
4
git clone https://aur.archlinux.org/microsoft-edge-stable-bin.git
cd microsoft-edge-stable-bin
git checkout fbccfd8fd911193c20bd4a19679133c182e64cf7
makepkg -si
  1. Reader View

Please use the below setting. If not, change it as you see fit and change the clipboard-to-html.sh script as well.

./images/reader-view.png

Setup

  1. Global shortcut

In my ~/.config/sway/config.d/default, I have the following keybinding:

bindsym $mod+e exec /home/username/.local/bin/clipboard-to-html.sh

Whenever I press Super+e, it executes the clipboard-to-html script.

Note
I suggest rebooting your system to make sure the global shortcut take effect. If you’re on Sway, swaymsg reload.
  1. Create the following directories and files
1
2
cd ~/Documents/books/clipboard/
touch clipboard.md index.html
  1. Create clipboard-to-html.sh
Note
Please see inline comments for what it does. Also make sure it’s executable.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash

# Available key names
# See /usr/include/linux/input-event-codes.h

src="/home/username/Documents/books/clipboard/clipboard.md"
output="/home/username/Documents/books/clipboard/index.html"

# 1. clipboard content to file
wl-paste >$src

# 2. pandoc convert md to html
pandoc -s -f markdown -t html5 -o $output $src -c style.css --wrap=none

# 3. get rid of smart quotes
sed -i -e "s/[$(echo -ne '\u2018\u2019')]/\'/g" -e "s/[$(echo -ne '\u201C\u201D')]/\"/g" $output

# 4. focus Edge
swaymsg "[app_id=\"microsoft-edge\"] focus"

# Esc twice to exit reader-view
ydotool key 1:1 1:0
sleep 0.1
ydotool key 1:1 1:0
sleep 0.5
# Alt-2 to focus tab
ydotool key 56:1 3:1 3:0 56:0
sleep 0.5
# Ctrl-r to reload the browser
ydotool key 29:1 19:1 19:0 29:0
sleep 0.5
# Ctrl-e to start `reader-view`
ydotool key 29:1 18:1 18:0 29:0
sleep 0.5
# `a` to start voice
ydotool key 30:1 30:0

Try to run clipboard-to-html.sh in the terminal to see if it works.

  1. Start a local server
1
2
cd ~/Documents/books/clipboard/
python3 -m http.server 8000

We use python to start a local server. Visit http://0.0.0.0:8000/ to see if you can connect to it.

  1. Now try it! Copy something to the clipboard with C-c, then press Super+e to trigger the script.

From the video, I only press C-c to copy the content I want, then press Super+e to trigger the global script. The rest is automated from the script.

This also works for local epub.

  1. Use Calibre to convert epub to html.
  2. Go to the output folder and start another python server with a different port (e.g., python3 -m http.server 8001).
  3. Visit http://0.0.0.0:8001/ to enjoy reading

Conclusion

I hope this is helpful.