eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

local_server.sh 1.3KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # https://stackoverflow.com/a/24777120
  3. send_message() {
  4. message="$1"
  5. # Calculate the byte size of the string.
  6. # NOTE: This assumes that byte length is identical to the string length!
  7. # Do not use multibyte (unicode) characters, escape them instead, e.g.
  8. # message='"Some unicode character:\u1234"'
  9. messagelen=${#message}
  10. # Convert to an integer in native byte order.
  11. # If you see an error message in Chrome's stdout with
  12. # "Native Messaging host tried sending a message that is ... bytes long.",
  13. # then just swap the order, i.e. messagelen1 <-> messagelen4 and
  14. # messagelen2 <-> messagelen3
  15. messagelen1=$(( ($messagelen ) & 0xFF ))
  16. messagelen2=$(( ($messagelen >> 8) & 0xFF ))
  17. messagelen3=$(( ($messagelen >> 16) & 0xFF ))
  18. messagelen4=$(( ($messagelen >> 24) & 0xFF ))
  19. # Print the message byte length followed by the actual message.
  20. printf "$(printf '\\x%x\\x%x\\x%x\\x%x' \
  21. $messagelen1 $messagelpen2 $messagelen3 $messagelen4)%s" "$message"
  22. }
  23. local_server() {
  24. if pgrep -f 'php -S localhost:8000' > /dev/null; then
  25. pkill -f 'php -S localhost:8000' & send_message '"Local server off."'
  26. else
  27. php -S localhost:8000 & send_message '"Local server on."'
  28. fi
  29. }
  30. local_server