2018-11-09 13:06:37 +00:00
|
|
|
---
|
|
|
|
layout: page
|
2018-11-11 11:00:42 +00:00
|
|
|
category-page: basic
|
2018-11-16 12:47:48 +00:00
|
|
|
category-title: Basic commands
|
2018-11-11 11:00:42 +00:00
|
|
|
tags: say
|
|
|
|
author: Gianmarco De Vita
|
|
|
|
title: say
|
2018-11-18 20:38:56 +00:00
|
|
|
previous-page: pages/cmd/basic/7-clear.html
|
|
|
|
next-page: pages/cmd/basic/9-whatis.html
|
2018-11-09 13:06:37 +00:00
|
|
|
---
|
2018-11-15 20:09:21 +00:00
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
You can convert text into audible speech just by writing the command
|
|
|
|
<code>say</code> followed by a string.
|
|
|
|
This is possible thanks to the <i>Speech Synthesis manager</i> on Mac OS.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
say string
|
2018-11-11 11:00:42 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
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.<br><br>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<h3>Read a particular file</h3>
|
2018-11-12 10:47:50 +00:00
|
|
|
By writing the command followed by the flag <code>-f</code> 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.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
say -f path/text.txt
|
2018-11-18 17:39:51 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<h3>Specify the reading voice</h3>
|
2018-11-12 10:47:50 +00:00
|
|
|
By writing the flag <code>-v</code> followed by a person name and a string, you
|
|
|
|
can decide which voice should read the string.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
say -v name string
|
2018-11-11 11:00:42 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
Of course, you're not expected to know every possible voice,
|
|
|
|
so, by writing a string (eg: "Hello world") as argument of the command
|
|
|
|
(including also the flag -v), you will get a list of all the available voices.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
say -v "Hello world"
|
2018-11-18 17:39:51 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<h3>Specify the Speech Rate</h3>
|
2018-11-12 10:47:50 +00:00
|
|
|
By writing the flag <code>-r</code> followed by a rate and then by a
|
|
|
|
string, you can decide the reading speed in words per minute.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
ay -r rate string
|
2018-11-18 17:39:51 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<h3>Store the output in an audible file</h3>
|
2018-11-12 10:47:50 +00:00
|
|
|
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 <code>-o</code> followed
|
|
|
|
by the path/name of the output file and then the string that has to be read.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
say -o path/audiofile.*format string
|
2018-11-11 11:00:42 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
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. Naturally,
|
|
|
|
you have to create the text files if they don't exist (with some text
|
|
|
|
inside), to make the work.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
say -v Alex -f hello_world.txt
|
2018-11-11 11:00:42 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-11 11:00:42 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
say -o hi.aac -f hello_world.txt
|
2018-11-11 11:00:42 +00:00
|
|
|
</pre>
|