Update and rename Speech_synthesis.md to speech_synthesis-(experimental).md
This commit is contained in:
@ -1,15 +0,0 @@
|
||||
### Speech synthesis
|
||||
|
||||
Currently The SpeechSynthesisUtterance interface of the Web Speech API represents a speech request.
|
||||
It contains the content the speech service should read and information about how to read it (e.g. language, pitch and volume.)
|
||||
|
||||
To know more - https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance
|
||||
|
||||
```
|
||||
const speak = message => {
|
||||
const msg = new SpeechSynthesisUtterance(message);
|
||||
msg.voice = window.speechSynthesis.getVoices()[0];
|
||||
window.speechSynthesis.speak(msg);
|
||||
}
|
||||
speak('Hello, World')
|
||||
```
|
||||
15
snippets/speech_synthesis-(experimental).md
Normal file
15
snippets/speech_synthesis-(experimental).md
Normal file
@ -0,0 +1,15 @@
|
||||
### Speech synthesis (experimental)
|
||||
|
||||
Use `SpeechSynthesisUtterance.voice` and `indow.speechSynthesis.getVoices()` to convert a message to speech.
|
||||
Use `window.speechSynthesis.speak()` to play the message.
|
||||
|
||||
Learn more about the [SpeechSynthesisUtterance interface of the Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance).
|
||||
|
||||
```js
|
||||
const speak = message => {
|
||||
const msg = new SpeechSynthesisUtterance(message);
|
||||
msg.voice = window.speechSynthesis.getVoices()[0];
|
||||
window.speechSynthesis.speak(msg);
|
||||
}
|
||||
// speak('Hello, World') -> plays the message
|
||||
```
|
||||
Reference in New Issue
Block a user