GithubHelp home page GithubHelp logo

gnat / text-to-speech-ubuntu Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 3.0 1.48 MB

๐Ÿ™Š Setup "selectable" text to speech / TTS on Ubuntu Linux 24.04 22.04 22.10 23.04 23.10 . Ideal for speed reading, programming, editing and writing.

tts keyboard-shortcuts speech ubuntu espeak espeak-ng ubuntu-mate

text-to-speech-ubuntu's Introduction

Text to Speech (TTS) Shortcut Ubuntu

For speed reading, researching, programming, editing and writing.

Tested on Ubuntu 24.04, 22.04, 22.10, 23.04, 23.10, but should work on similar distributions such as Mint, Debian, Pop OS. xsel required so espeak can read from clipboard. Works with espeak or espeak-ng.

  1. sudo apt install espeak xsel -y
  2. Set your custom shortcuts. See Gnome or KDE below.
  3. With your mouse, select text you want read aloud, press your Read keys.

Gnome

  • System Settings โžก Keyboard โžก Keyboard Shortcuts โžก Custom Shortcuts โžก +
  • Read bash -c "espeak -s260 -g0 -p40 -v english-us \"$(xsel | sed -e :a -e 'N;s/\n/ /;ta')\""
  • Stop Reading bash -c "killall espeak"
  • Recommended keys SUPER + R (Read) and SHIFT + SUPER + R (Stop Reading)
  • With your mouse, select text you want read aloud, press your Read keys.

screenshot

KDE

KDE is a little different because custom shortcuts have an issue with multiple commands in the same action, but this works:

  • System Settings โžก Shortcuts โžก Custom Shortcuts โžก Edit .. New .. Global .. Command
  • Read xsel > /tmp/speak.txt | espeak -s260 -g0 -p40 -v english-us -f /tmp/speak.txt
  • Stop Reading killall espeak
  • Recommended keys SUPER + R (Read) and SHIFT + SUPER + R (Stop Reading)
  • With your mouse, select text you want read aloud, press your Read keys.

Screenshot_20231024_225433

Options

  • -s260 Speed of reading (260 is faster).
  • -g0 Delay between words (0 is no delay).
  • -p40 Pitch (50 is normal).
  • -v english-us Voice pack (en-us for espeak-ng).

Sed explainer.

The sed is required to replace newlines properly. Reference: https://linux.die.net/man/1/sed

  • -e :a Sets a label for looping.
  • N Read next line into substitute buffer ... or $!N ($ go to EOL, !N exit if no more newlines to read)
  • ;s/\n/ / Substitute newlines with space.
  • ;ta Loop to label a.

Using espeak-ng instead of espeak

Some distributions come with espeak-ng which can be used with only minor changes.

  1. Read bash -c "espeak-ng -s260 -g0 -p40 -v en-us \"$(xsel | sed -e :a -e 'N;s/\n/ /;ta')\""
  2. Stop Reading bash -c "killall espeak-ng"

Killing espeak if needed.

  • ps -ef | grep "espeak" | tr -s ' ' | cut -d ' ' -f2 | xargs kill -9

Why?

Because my favorite TTS reader gespeaker (python frontend to espeak) is unmaintained, and most other options suck or are browser only.

text-to-speech-ubuntu's People

Contributors

gnat avatar timintegration avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

text-to-speech-ubuntu's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.