Creating a script for TTS Mimic3 and binding a hotkey using xbindkeys
by libreuser from LinuxQuestions.org on (#6CTF9)
Hi everybody!
Recently I started using Linux Mint and I've been configuring the system according to my needs since then. I used MacOS for years and, so, I'm used to some useful Apple features, which are absent on Linux by default.
Now I'm trying to re-create the TTS feature from MacOS. I've been using it for many years and it comes in handy.
I found a decent TTS engine called Mimic3.
Then I wrote a script to use Mimic3 along with Xclip.
Code:#!/bin/bash
# Get highlighted text from the clipboard
text=$(xclip -o -selection primary)
# Check if there is any highlighted text
if [[ -n "$text" ]]; then
# Invoke mimic3 to pronounce the text
mimic3 "$text"
else
# If no text is highlighted, display an error message
echo "No text is highlighted."
fiI saved the script as pronounce.sh and installed Xbindkeys in order to create a hotkey for using Mimic3 during my workflow.
I added the following lines to ~/.xbindkeysrc
Code:"/home/cryptoslav/Desktop/pronounce.sh"
Control + Escape
"brave-browser"
Control + lThe first bound key is for the script and the second one is for checking xbindkeys.
During testing with 'xbindkeys -n' in terminal both keys worked well.
Then I used 'xbindkeys &' in order to use the keys without opened terminal.
Even though I could open Brave using 'control + l', the script didn't work when I pressed 'control + escape'.
I've been racking my brain for several days now, but all my attempts have been in vain.
I would appreciate any help in this matter.
Recently I started using Linux Mint and I've been configuring the system according to my needs since then. I used MacOS for years and, so, I'm used to some useful Apple features, which are absent on Linux by default.
Now I'm trying to re-create the TTS feature from MacOS. I've been using it for many years and it comes in handy.
I found a decent TTS engine called Mimic3.
Then I wrote a script to use Mimic3 along with Xclip.
Code:#!/bin/bash
# Get highlighted text from the clipboard
text=$(xclip -o -selection primary)
# Check if there is any highlighted text
if [[ -n "$text" ]]; then
# Invoke mimic3 to pronounce the text
mimic3 "$text"
else
# If no text is highlighted, display an error message
echo "No text is highlighted."
fiI saved the script as pronounce.sh and installed Xbindkeys in order to create a hotkey for using Mimic3 during my workflow.
I added the following lines to ~/.xbindkeysrc
Code:"/home/cryptoslav/Desktop/pronounce.sh"
Control + Escape
"brave-browser"
Control + lThe first bound key is for the script and the second one is for checking xbindkeys.
During testing with 'xbindkeys -n' in terminal both keys worked well.
Then I used 'xbindkeys &' in order to use the keys without opened terminal.
Even though I could open Brave using 'control + l', the script didn't work when I pressed 'control + escape'.
I've been racking my brain for several days now, but all my attempts have been in vain.
I would appreciate any help in this matter.