How to modulate the voices reading in YOSEMITE?

I have seen the
SAY command in many posts but I can’t find it in my dictionary in TextEdit nor the ScriptEditor
I would like to be able to read a dialogue in textedit assigning various voices with various speeds.
I found this script
say “Hello my friend” using “Alex”
which works just fine as it is.
Is it possible to create a script which simply calls a text file of choice and
changes the rate and/or the pitch incorporating the terminal commands in applescript?
as
say -v Alex “Hello” -r 200

THIS ISn’T A SCRIPT BUT WHAT I HOPE TO ACHIEVE

CHOOSE FILE WITH PROMPT
TELL APPLICATION TO
SAY CONTENT OF FILE
using "Alex"with rate 100

thanks a lot

Hi.

‘say’ is in the StandardAdditions. It has quite a few options, including for speaking rate, pitch, and modulation. You’ll have to experiment to see (or hear) the effects with each voice.

say "Hello" using "Alex" speaking rate 100 pitch 60
delay 0.5
say "Hello" using "Alex" speaking rate 100 pitch 20

It’s possible to embed commands in the text to be spoken to control individual nuances, but it’s advanced stuff! https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/Introduction/Introduction.html

Thank you very much NIgel you are always extremely kind, taking care of many users ever since I entered this forum more than a decade ago.

I assembled this script based on your suggestion:


set OLIVER to (choose file) as string
tell application "TextEdit"	
	set dialogo to text of OLIVER
	if dialogo is not "" then
		say dialogo using "Daniel" speaking rate 100 pitch 60		
	end if
end tell

However TextEdit reads the path of the chosen file and skips the content
How can i fix the script so it will avoid reading the path and return the content instead.

I am using the UK AUSTRALIAN RUSSIAN voices as they are the only ones responding properly to all APPLE voice specifications as from your suggestions.
Most others (after very intensive tests) don’t or they respond to some and not others

Thanks again from an old Italian-Taiwanese user

Man Dan Wan

Hi Man Dan Wan.

If you’re using TextEdit, it has to open the file first and then return the text of the resulting document:


set OLIVER to (choose file)

tell application "TextEdit"
	set dialogo to text of (open OLIVER)
end tell

if dialogo is not "" then
	say dialogo using "Daniel" speaking rate 100 pitch 60
end if

But you only need to use TextEdit if the text in the file is (or may be) in RTF format. If the file contains simple UTF-8 Unicode text, you may as well read its contents directly:

set OLIVER to (choose file)

set dialogo to (read OLIVER as «class utf8»)

if dialogo is not "" then
	say dialogo using "Daniel" speaking rate 100 pitch 60
end if

THank you it works perfectly