--- layout: page author: De Vita Gianmarco title: SAY ---

You can convert text into audible speech just by writing the command say followed by a string. This is possible thanks to the Speech Synthesis manager.

{% highlight ruby linenos %} Device-name:Current-position username$ say string {% endhighlight %}

Naturally, the wide presence of flags for this command allows you to use this command for many different tasks. Notice that using more flag simultaneously, you will be able to solve more complex operations.

Read a particular file

By writing the command followed by the flag -f and, instead of the string, by the path of a text file, you will get as output a voice reading the content of that file.

{% highlight ruby linenos %} Device-name:Current-position username$ say -f path/text.txt {% endhighlight %}

Specify the reading voice

By writing the flag -v followed by a person name and a string, you can decide which voice should read the string.

{% highlight ruby linenos %} Current-position username$ say -v name string {% endhighlight %}

Notice. Of course, you're not expected to know every possible voice, so, by writing "?" as argument of the command (including also the flag -v), you will get a list of all the available voices.

{% highlight ruby linenos %} Current-position username$ say -v ? {% endhighlight %}

Specify the Speech Rate

By writing the flag -r followed by a rate and then by a string, you can decide the reading speed in words per minute.

{% highlight ruby linenos %} Current-position username$ say -r rate string {% endhighlight %}

Store the output in an audible file

You can save the result of the command in an audible file. To do that, you have just to write after the command the flag -o followed by the path/name of the output file and then the string that has to be read.

{% highlight ruby linenos %} Current-position username$ say -o path/audiofile.*format string {% endhighlight %}

Exercise - Flags combinations

As said above, you can use more flags in the same command, once you know well them. See the examples below and try to guess the output. You can copy these commands into your terminal to verify your answers.

{% highlight ruby linenos %} Current-position username$ say -v Alex -f hello_world.txt {% endhighlight %} {% highlight ruby linenos %} Current-position username$ say -o hi.aac -f hello_world.txt {% endhighlight %}