title: Cannot set prototype of SpeechSynthesisVoice manually
body: <p>This question is somewhat for understanding the prototype get-set.</p>
  
  <p>I've a scenario where I need to map the <strong>SpeechSynthesis</strong> supported voice to <strong>Google Translation API</strong> supported language codes.
  For example,</p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/OQc4e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OQc4e.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>Now, I can do the same by either fetching the voices runtime or by storing the voice and hard-coding the mapping in some method in javascript.
  If I go for runtime approach, I need to call <code>getVoice()</code> in <code>speechSynthesis.onvoiceschanged = () =&gt; {}</code> and then map the numbers, which gets called in every voice change event. So, I want to go for hard-coding one.</p>
  
  <p>Now, when I store the mapping array in a variable and call it by index, I get the SpeechSynthesisVoice Object, just like what we do in <code>getVoices()[index]</code>.</p>
  
  <p>Further, If I set this object value to <code>speechSynthesis.voice</code>, I get an error:</p>
  
  <pre><code>Uncaught TypeError: Failed to set the 'voice' property on 'SpeechSynthesisUtterance': The provided value is not of type 'SpeechSynthesisVoice'.
  </code></pre>
  
  <p>This is due to mis-match of prototype of the manually stored object value.</p>
  
  <p>For example,</p>
  
  <p><strong>1. SpeechSynthesisVoice object:</strong></p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/Neb3g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Neb3g.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p><strong>2. Manually stored value of SpeechSynthesisVoice object:</strong></p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/GxOJ5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GxOJ5.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>To resolve, this I've fetched the <strong>proto</strong> of the SpeechSynthesisVoice object using <code>getVoice()</code>, and then set it to a variable and further, set this variable to my manual mapped object.
  Like,</p>
  
  <p>Get:</p>
  
  <pre><code>voicePrototype = getVoices()[9].__proto__;
  </code></pre>
  
  <p>Set:</p>
  
  <pre><code>voices[index].SpeechSynthesisVoice.__proto__ = voicePrototype;
  </code></pre>
  
  <p>And, it gets set, as in below screenshot:</p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/QFUGb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QFUGb.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>I've also tried through <code>Object.setPrototypeOf()</code> and got the same result.</p>
  
  <p>Now, again when I want to set this object to <code>speechSynthesis.voice</code>, I still get the same error, although my prototype matches.</p>
  
  <p>Can anyone, please advise, if its possible to set the object proto likewise and use it? Thanks in advance.</p>