JSON.stringify issue

JSON.stringify does not work for SpeechSynthesisVoice objects

by LeoLux

HTML

<textarea id="output" rows="30" cols="50"></textarea>

JavaScript

function out(text) {
  var output = document.getElementById('output');
  output.value = output.value + text + '\n';
}


window.onload = function() {
  if (!!window.speechSynthesis) {
    var voices = window.speechSynthesis.getVoices();
    console.log('number of voices: ' + voices.length);
    out('number of voices: ' + voices.length);

    var voiceObject = voices[0];
    console.log('voiceObject: ' + voiceObject);
    out('voiceObject: ' + voiceObject);

    //Show the properties of the object
    var name = voiceObject.name;
    var lang = voiceObject.lang;
    var localService = voiceObject.localService;
    console.log('Properties: ' + name + ' | ' + lang + ' | ' + localService);
    out('Properties: ' + name + ' | ' + lang + ' | ' + localService);

    //Stringify the voice object
    var stringified = JSON.stringify(voiceObject); //returns {}??
    console.log('stringified: ' + stringified);
    out('stringified: ' + stringified);

  } else {
    alert('No speechSynthesis support');
  }
};