Since you are piping the output of the
pbpaste command directly to
say command, then e.g.
[[volm 0.35]] would need to be a part of what's on the clipboard as e.g.
[[volm 0.35]] must precede the content of what was actually going to be said.
I'd try using the following in place of what you are using:
set howLoudAndWhatToSay to "[[volm 0.35]] \"" & (get the clipboard as string) & "\""
set this_say_Pid to do shell script "say " & howLoudAndWhatToSay & " > /dev/null 2>&1 & echo $!"
Update: If you want to stick with using
pbpaste, then this example command should work:
set this_say_Pid to (do shell script "echo \"[[volm 0.35]] $(LANG=en_US.UTF-8 pbpaste -Prefer txt)\" | say > /dev/null 2>&1 & echo $!")
Note the primary differences between the command within the
do shell script "..." command in your question and my answer.
echo \"[[volm 0.35]] is added in front of
LANG=... and note the space after
LANG=en_US.UTF-8 pbpaste -Prefer txt is now enclosed in
$(...) which is using Command Substitution to, in essence, concatenate what gets echoed to the pipe ahead of the
As well as a matching closing literal double-quote
\", before the pipe to
say, to go with the one in
echo \"[[volm 0.35]]. It did work in limited testing without the use of the opening and closing double-quotes however it's probably better to encase it in the double-quotes to account for something the shell might try to unnecessarily expand.
That said, on my system using
0.35 for the value in
[[volm 0.35]] didn't work well in that is was difficult to perceive the difference in volume from my normal setting. However using
[[volm 0.3]] the difference was notable. (This is one of the reasons why I used "e.g.
[[volm 0.35]]" in my opening sentence.)