Jump to content

Say (text-to-speech) with option of voices.

Recommended Posts

Hey all,


I've created a text-to-speech workflow based on Mac OS's 'say' command. With it you type 'say' followed by 'what you want to say'. You are then given a list of installed voices to pick from. Select a voice with the arrows or simply hit enter to have your phrase spoken aloud.


I've also included an additional novelty command 'sayslow' which will speak your phrase in your chosen voice at a veeerryy slow rate. I don't know why but I find this incredibly comical.




- I made the script much more stable in the way it is handling escaping special characters.

- The code is much more DRY.

- It is now easier to extend with more voice styles (i.e. sayfast would be possible as well).



Edited by shmuel
Link to comment

Never used the text-to-speech of my mac, but I believe it will be useful to make sure of the pronounciation of English words (I'm not a native speaker).
Plus, there are fun voices to pick :)


Thanks for that !


Edit : I noticed that it's necessary to use a simple quote (') to spell more than one word. Without quotes or with double quotes (") it doesn't work.

Edit2 : would it be possible for the worflow to remember the last used voice, and put it in first choice?

Edited by Cedric
Link to comment

Hey Cedric,


I'm glad you found it useful (or at least entertaining). If you select the same voice a few times in a row it should rise to the top of the list. Over time Alfred will prioritize the list based on how frequently you use each voice. It should work fine without quotes (single or double). There is a known bug with apostrophes. If you type "didn't" (no quotes) it will do nothing. This is a problem with how I am escaping this string (or not escaping it). I'll try to figure out how to improve that and post it when I have it sorted.

Link to comment

OK Cedric,


I've updated the workflow. It now works correctly with single quotes / apostrophes. It does not work with double quotes. In fact a double quote will still cause it to fail but I think that is preferable to the way it was perviously. Let me know if it works for you now.

Link to comment



When you mean double quote, you mean (") right ? Because, now the behaviour is the opposite as what it used to be.

I used to have to enter 'hello world', else the voices wouldn't load (it would be stuck on keep loading).
Now I have to enter "hello world", as the voices won't load with a single quote.

If I try "I don't know", it will go fine until the ('), then i alfred will display the default search fallbacks instead of the voices.


Is it the expected behaviour?

Link to comment
  • 2 years later...

This is a good idea :)


I tried it but im having a problem. When i type the first character of the query, it shows the fallback result (eg google searches).


Here's what's in the log:


Starting debug for 'Say Something'


[ERROR: alfred.workflow.input.scriptfilter] Code 1: -e:4:in `split': invalid byte sequence in US-ASCII (ArgumentError)

from -e:4:in `<main>'

[ERROR: alfred.workflow.input.scriptfilter] Code 1: -e:4:in `split': invalid byte sequence in US-ASCII (ArgumentError)

from -e:4:in `<main>'

[ERROR: alfred.workflow.input.scriptfilter] Code 1: -e:4:in `split': invalid byte sequence in US-ASCII (ArgumentError)

from -e:4:in `<main>'


Please help. Eager to use your workflow :)




- Jayson

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...