Here is a fully working script, which uses the say command to speak the selected text:
(async ()=> {
let selectedText = await callBTT('get_string_variable', {variable_name:'selected_text'})
// put the shell script into a string (single backticks are great for multiline strings)
let shellScript = `say ${selectedText}`;
let shellScriptWrapper = {
script: shellScript
};
let result = await runShellScript(shellScriptWrapper);
returnToBTT(result)
})();