Tech Tip: Text to speech in Mac OSX say command
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac
Published On: May 14, 2018
Mac OSX has a Text to speech command to annunciate words of text or in text file. Here is a utility method that can input a text or text file location to hear a text to speech:
// ----------------------------------------------------------------- // Name: MAC_SAY_TEXT // Description: Invokes the "say" command in terminal // output a text sound annunciation. // // Input Parameters: // $1 (TEXT) - Text or Location of text file. // ------------------------------------------------------------------ C_TEXT($1;$inputTextLoc;$cmd;$input;$output;$error) If (Count parameters=1) $inputTextLoc:=$1 If (test path name($inputTextLoc)=Is a document) $cmd:="say -f "+convert path system to posix($inputTextLoc) Else $cmd:="say "+$inputTextLoc End if $input:="" SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true") SET ENVIRONMENT VARIABLE("_4D_OPTION_BLOCKING_EXTERNAL_PROCESS";"false") LAUNCH EXTERNAL PROCESS($cmd;$input;$output;$error) End if |
Example #1: Input a text
MAC_SAY_TEXT("Hello 4D!") |
Example #2: Specify a text file location
C_TEXT($loc) $loc:=get 4d Folder(Current resources folder)+"test.txt" MAC_SAY_TEXT($loc) |