In my googlesheets app script (I am new to google sheets, but so glad they built off of javascript!), I wish reuse one of my javascript functions that works fine in my browser:
function playSoundGoogleTTS(greekText) {
const greekTtsUrl= `https://translate.google.com/translate_tts?ie=UTF-8&tl=el&client=tw-ob&q=${greekText}`;
// use the browser's audio
let audioPlayerElem = document.getElementById("audioPlayer");
audioPlayerElem.src = ttsUrl;
audioPlayerElem.play();
}
I have rewritten the above function, since this is not running in a browser to use the recommended UrlFetchApp:
function playSoundGoogleTTS(greekText, langPronValue) {
const greekTtsUrl= `https://translate.google.com/translate_tts?ie=UTF-8&tl=el&client=tw-ob&q=${greekText}`;
// NOT using browser to play audio
var googleResp = UrlFetchApp.fetch(ttsUrl);
console.log(googleResp);
}
but although this returns successfully, there is no sound redirected to my speakers. I have no way to debug this either that I know of, the way I could with chrome dev tools.
I have searched the docs for UrlFetchApp and find nothing to help me here. I have googled around retrieving the blob response from UrlFetchApp and then trying to play this explicitly, but find no pointers. Any ideas?