recursal/MDN huggingface dataset:
SpeechRecognition: abort() method
=================================

 The **`abort()`** method of the Web Speech API stops the speech
 recognition service from listening to incoming audio, and doesn't attempt to return a
 `SpeechRecognitionResult`.

Syntax
------


```js
abort()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------


```js
const grammar =
  "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
const recognition = new SpeechRecognition();
const speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;

const diagnostic = document.querySelector(".output");
const bg = document.querySelector("html");

document.body.onclick = () => {
  recognition.start();
  console.log("Ready to receive a color command.");
};

abortBtn.onclick = () => {
  recognition.abort();
  console.log("Speech recognition aborted.");
};

recognition.onspeechend = () => {
  recognition.stop();
  console.log("Speech recognition has stopped.");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # dom-speechrecognition-abort |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: grammars property
====================================

 The **`grammars`** property of the
 `SpeechRecognition` interface returns and sets a collection of
 `SpeechGrammar` objects that represent the grammars that will be understood
 by the current `SpeechRecognition`.

Value
-----

 A `SpeechGrammarList` containing the `SpeechGrammar` objects
 that represent your grammar for your app.

Examples
--------

 This code is excerpted from our
 Speech color changer example.


```js
const grammar =
  "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
const recognition = new SpeechRecognition();
const speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
//recognition.continuous = false;
recognition.lang = "en-US";
recognition.interimResults = false;
recognition.maxAlternatives = 1;

// ...
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # dom-speechrecognition-grammars |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: soundend event
=================================

The **`soundend`** event of the Web Speech API is fired when any sound — recognizable speech or not — has stopped being detected.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("soundend", (event) => {});

onsoundend = (event) => {};
```

Event type
----------

A generic `Event` with no added properties.

Examples
--------

You can use the `soundend` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("soundend", (event) => {
  console.log("Sound has stopped being received");
});
```


Or use the `onsoundend` event handler property:


```js
recognition.onsoundend = (event) => {
  console.log("Sound has stopped being received");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-soundend |
| Web Speech API # dom-speechrecognition-onsoundend |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: speechend event
==================================

The **`speechend`** event of the Web Speech API is fired when speech recognized by the speech recognition service has stopped being detected.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("speechend", (event) => {});

onspeechend = (event) => {};
```

Event type
----------

A generic `Event` with no added properties.

Examples
--------

You can use the `speechend` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("speechend", () => {
  console.log("Speech has stopped being detected");
});
```


Or use the `onspeechend` event handler property:


```js
recognition.onspeechend = () => {
  console.log("Speech has stopped being detected");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-speechend |
| Web Speech API # dom-speechrecognition-onspeechend |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: end event
============================

The **`end`** event of the Web Speech API `SpeechRecognition` object is fired when the speech recognition service has disconnected.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("end", (event) => {});

onend = (event) => {};
```

Event type
----------

A generic `Event` with no added properties.

Examples
--------

You can use the `end` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("end", () => {
  console.log("Speech recognition service disconnected");
});
```


Or use the `onend` event handler property:


```js
recognition.onend = () => {
  console.log("Speech recognition service disconnected");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-end |
| Web Speech API # dom-speechrecognition-onend |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: stop() method
================================

 The **`stop()`** method of the Web Speech API stops the speech
 recognition service from listening to incoming audio, and attempts to return a
 `SpeechRecognitionResult` using the audio captured so far.

Syntax
------


```js
stop()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------


```js
const grammar =
  "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
const recognition = new SpeechRecognition();
const speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;

const diagnostic = document.querySelector(".output");
const bg = document.querySelector("html");

document.body.onclick = () => {
  recognition.start();
  console.log("Ready to receive a color command.");
};

abortBtn.onclick = () => {
  recognition.abort();
  console.log("Speech recognition aborted.");
};

recognition.onspeechend = () => {
  recognition.stop();
  console.log("Speech recognition has stopped.");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # dom-speechrecognition-stop |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: continuous property
======================================

 The **`continuous`** property of the
 `SpeechRecognition` interface controls whether continuous results are
 returned for each recognition, or only a single result.

It defaults to single results (`false`.)

Value
-----

 A boolean value representing the current `SpeechRecognition`'s
 continuous status. `true` means continuous, and `false` means not
 continuous (single result each time.)

Examples
--------

This code is excerpted from our Speech color changer example.


```js
const grammar =
  "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
const recognition = new SpeechRecognition();
const speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
recognition.continuous = false;
recognition.lang = "en-US";
recognition.interimResults = false;
recognition.maxAlternatives = 1;

// ...
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # dom-speechrecognition-continuous |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: audioend event
=================================

The **`audioend`** event of the Web Speech API is fired when the user agent has finished capturing audio for speech recognition.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("audioend", (event) => {});

onaudioend = (event) => {};
```

Event type
----------

A generic `Event` with no added properties.

Examples
--------

You can use the `audioend` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("audioend", () => {
  console.log("Audio capturing ended");
});
```


Or use the `onaudioend` event handler property:


```js
recognition.onaudioend = () => {
  console.log("Audio capturing ended");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-audioend |
| Web Speech API # dom-speechrecognition-onaudioend |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: error event
==============================

The **`error`** event of the Web Speech API `SpeechRecognition` object is fired when a speech recognition error occurs.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("error", (event) => {});

onerror = (event) => {};
```

Event type
----------

A `SpeechRecognitionErrorEvent`. Inherits from `Event`.

Event

SpeechRecognitionErrorEventEvent properties
----------------

*In addition to the properties listed below, properties from the parent interface, `Event`, are available.*

`SpeechRecognitionErrorEvent.error` Read only 

Returns the type of error raised.

`SpeechRecognitionErrorEvent.message` Read only 

Returns a message describing the error in more detail.

Examples
--------

You can use the `error` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("error", (event) => {
  console.error(`Speech recognition error detected: ${event.error}`);
});
```


Or use the `onerror` event handler property:


```js
recognition.onerror = (event) => {
  console.error(`Speech recognition error detected: ${event.error}`);
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-error |
| Web Speech API # dom-speechrecognition-onerror |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: lang property
================================

 The **`lang`** property of the `SpeechRecognition`
 interface returns and sets the language of the current `SpeechRecognition`.
 If not specified, this defaults to the HTML `lang` attribute
 value, or the user agent's language setting if that isn't set either.

Value
-----

A string representing the BCP 47 language tag for the current `SpeechRecognition`.

Examples
--------

This code is excerpted from our Speech color changer example.


```js
const grammar =
  "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
const recognition = new SpeechRecognition();
const speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
//recognition.continuous = false;
recognition.lang = "en-US";
recognition.interimResults = false;
recognition.maxAlternatives = 1;

// ...
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # dom-speechrecognition-lang |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: audiostart event
===================================

The **`audiostart`** event of the Web Speech API is fired when the user agent has started to capture audio for speech recognition.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("audiostart", (event) => {});

onaudiostart = (event) => {};
```

Event type
----------

A generic `Event` with no added properties.

Examples
--------

You can use the `audiostart` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("audiostart", () => {
  console.log("Audio capturing started");
});
```


Or use the `onaudiostart` event handler property:


```js
recognition.onaudiostart = () => {
  console.log("Audio capturing started");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-audiostart |
| Web Speech API # dom-speechrecognition-onaudiostart |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: speechstart event
====================================

The **`speechstart`** event of the Web Speech API is fired when sound recognized by the speech recognition service as speech has been detected.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("speechstart", (event) => {});

onspeechstart = (event) => {};
```

Event type
----------

A generic `Event` with no added properties.

Examples
--------

You can use the `speechstart` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("speechstart", () => {
  console.log("Speech has been detected");
});
```


Or use the `onspeechstart` event handler property:


```js
recognition.onspeechstart = () => {
  console.log("Speech has been detected");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-speechstart |
| Web Speech API # dom-speechrecognition-onspeechstart |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: result event
===============================

The **`result`** event of the Web Speech API is fired when the speech recognition service returns a result — a word or phrase has been positively recognized and this has been communicated back to the app

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("result", (event) => {});

onresult = (event) => {};
```

Event type
----------

A `SpeechRecognitionEvent`. Inherits from `Event`.

Event

SpeechRecognitionEventEvent properties
----------------

*In addition to the properties listed below, properties from the parent interface, `Event`, are available.*

`SpeechRecognitionEvent.emma` Read only 

Returns an Extensible MultiModal Annotation markup language (EMMA) — XML — representation of the result.

`SpeechRecognitionEvent.interpretation` Read only 

Returns the semantic meaning of what the user said.

`SpeechRecognitionEvent.resultIndex` Read only 

Returns the lowest index value result in the `SpeechRecognitionResultList` "array" that has actually changed.

`SpeechRecognitionEvent.results` Read only 

Returns a `SpeechRecognitionResultList` object representing all the speech recognition results for the current session.

Examples
--------

This code is excerpted from our Speech color changer example.

You can use the `result` event in an `addEventListener` method:


```js
const recognition = new SpeechRecognition();

recognition.addEventListener("result", (event) => {
  const color = event.results[0][0].transcript;
  diagnostic.textContent = `Result received: ${color}.`;
  bg.style.backgroundColor = color;
});
```


Or use the `onresult` event handler property:


```js
recognition.onresult = (event) => {
  const color = event.results[0][0].transcript;
  diagnostic.textContent = `Result received: ${color}.`;
  bg.style.backgroundColor = color;
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-result |
| Web Speech API # dom-speechrecognition-onresult |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: nomatch event
================================

The **`nomatch`** event of the Web Speech API is fired when the speech recognition service returns a final result with no significant recognition.

This may involve some degree of recognition, which doesn't meet or exceed the `confidence` threshold.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("nomatch", (event) => {});

onnomatch = (event) => {};
```

Event type
----------

A `SpeechRecognitionEvent`. Inherits from `Event`.

Event

SpeechRecognitionEventEvent properties
----------------

*In addition to the properties listed below, properties from the parent interface, `Event`, are available.*

`SpeechRecognitionEvent.emma` Read only 

Returns an Extensible MultiModal Annotation markup language (EMMA) — XML — representation of the result.

`SpeechRecognitionEvent.interpretation` Read only 

Returns the semantic meaning of what the user said.

`SpeechRecognitionEvent.resultIndex` Read only 

Returns the lowest index value result in the `SpeechRecognitionResultList` "array" that has actually changed.

`SpeechRecognitionEvent.results` Read only 

Returns a `SpeechRecognitionResultList` object representing all the speech recognition results for the current session.

Examples
--------

You can use the `nomatch` event in an `addEventListener` method:


```js
const recognition = new webkitSpeechRecognition() || new SpeechRecognition();

recognition.addEventListener("nomatch", () => {
  console.error("Speech not recognized");
});
```


Or use the `onnomatch` event handler property:


```js
recognition.onnomatch = () => {
  console.error("Speech not recognized");
};
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-nomatch |
| Web Speech API # dom-speechrecognition-onnomatch |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API
SpeechRecognition: interimResults property
==========================================

 The **`interimResults`** property of the
 `SpeechRecognition` interface controls whether interim results should be
 returned (`true`) or not (`false`.) Interim results are results
 that are not yet final (e.g. the `SpeechRecognitionResult.isFinal` property
 is `false`.)

The default value for **`interimResults`** is `false`.

Value
-----

 A boolean value representing the state of the current
 `SpeechRecognition`'s interim results. `true` means interim
 results are returned, and `false` means they aren't.

Examples
--------

This code is excerpted from our Speech color changer example.


```js
const grammar =
  "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
const recognition = new SpeechRecognition();
const speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
//recognition.continuous = false;
recognition.lang = "en-US";
recognition.interimResults = false;
recognition.maxAlternatives = 1;

// ...
```

Specifications
--------------

| Specification |
| --- |
| Web Speech API # dom-speechrecognition-interimresults |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Web Speech API