|
45 | 45 | |39|[Numeric separators allow us to improve our code readability](#Numeric-separators-allow-us-to-improve-our-code-readability)|
|
46 | 46 | |40|[pay attention when using every](#pay-attention-when-using-every)|
|
47 | 47 | |41|[How to convert an array of key-value tuples into an object](#How-to-convert-an-array-of-key-value-tuples-into-an-object)|
|
48 |
| - |
| 48 | +|42|[Native text to speech JS](#Native-text-to-speech-JS)| |
49 | 49 |
|
50 | 50 |
|
51 | 51 |
|
@@ -903,4 +903,25 @@ const obj = Object.fromEntries(JSarr);
|
903 | 903 | //}
|
904 | 904 | ```
|
905 | 905 |
|
| 906 | +**[⬆ Back to Top](#table-of-contents)** |
| 907 | +### Native text to speech JS |
| 908 | +
|
| 909 | +
|
| 910 | +```javascript |
| 911 | +
|
| 912 | +const startSpeaking=()=>{ |
906 | 913 |
|
| 914 | +let msg = document.getElementById("text-to-speech").value; |
| 915 | +let speech = new SpeechSynthesisUtterance(); |
| 916 | +
|
| 917 | +speech.lang ="en-US"; |
| 918 | +speech.text = msg; |
| 919 | +speech.volume = 1; |
| 920 | +speech.rate = 1; |
| 921 | +speech.pitch = 1; |
| 922 | +
|
| 923 | +window.speechSynthesis.speak(speech); |
| 924 | +} |
| 925 | +
|
| 926 | +
|
| 927 | +``` |