recursal/MDN huggingface dataset:
SpeechRecognition: soundstart event
===================================

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

Syntax
------

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


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

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

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

A generic `Event` with no added properties.

Examples
--------

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


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

recognition.addEventListener("soundstart", () => {
  console.log("Some sound is being received");
});
```


Or use the `onsoundstart` event handler property:


```js
recognition.onsoundstart = () => {
  console.log("Some sound is being received");
};
```

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

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-soundstart |
| Web Speech API # dom-speechrecognition-onsoundstart |

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

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

See also
--------

* Web Speech API
SpeechRecognition: SpeechRecognition() constructor
==================================================

 The **`SpeechRecognition()`** constructor creates a new
 `SpeechRecognition` object instance.

Syntax
------


```js
new SpeechRecognition()
```

### Parameters

None.

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-speechrecognition |

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

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

See also
--------

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

The **`start`** event of the Web Speech API `SpeechRecognition` object is fired when the speech recognition service has begun listening to incoming audio with intent to recognize grammars associated with the current `SpeechRecognition`.

Syntax
------

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


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

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

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

A generic `Event` with no added properties.

Examples
--------

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


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

recognition.addEventListener("start", () => {
  console.log("Speech recognition service has started");
});
```


Or use the `onstart` event handler property:


```js
recognition.onstart = () => {
  console.log("Speech recognition service has started");
};
```

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

| Specification |
| --- |
| Web Speech API # eventdef-speechrecognition-start |
| Web Speech API # dom-speechrecognition-onstart |

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

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

See also
--------

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

 The **`start()`** method of the Web Speech API starts the speech
 recognition service listening to incoming audio with intent to recognize grammars
 associated with the current `SpeechRecognition`.

Syntax
------


```js
start()
```

### 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-start |

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

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

See also
--------

* Web Speech API
DOMException: name property
===========================

 The **`name`** read-only property of the
 `DOMException` interface returns a string that contains
 one of the strings associated with an error name.

Value
-----

A string.

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

| Specification |
| --- |
| Web IDL Standard # dom-domexception-name |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
DOMException: code property
===========================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The **`code`** read-only property of the `DOMException` interface returns one of the legacy error code constants, or `0` if none match.

This field is used for historical reasons. New DOM exceptions don't use this anymore: they put this info in the `DOMException.name` attribute.

Value
-----

One of the error code constants, or `0` if none match.

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

| Specification |
| --- |
| Web IDL Standard # dom-domexception-code |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
DOMException: DOMException() constructor
========================================

 The **`DOMException()`** constructor returns a
 `DOMException` object with a specified message and name.

Syntax
------


```js
new DOMException()
new DOMException(message)
new DOMException(message, name)
```

### Parameters

`message` Optional

 A description of the exception. If not present, the empty string `''` is
 used.


`name` Optional

A string. If the specified name is a standard error name, then getting the `code` property of the `DOMException` object will return the code number corresponding to the specified name.

### Return value

A newly created `DOMException` object.

Examples
--------

In this example, pressing the button causes a custom `DOMException` to be thrown, which is then caught and the custom error message shown in an alert.

### HTML


```html
<button>Trigger DOM Exception</button>

<p id="output"></p>
```

### JavaScript


```js
const button = document.querySelector("button");

button.onclick = () => {
  try {
    throw new DOMException("Custom DOM Exception Triggered.");
  } catch (error) {
    document.querySelector("#output").textContent = `Error: ${error.message}`;
  }
};
```

### Result

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

| Specification |
| --- |
| Web IDL Standard # dom-domexception-domexception |

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

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

See also
--------

* A polyfill of `DOMException` constructor is available in `core-js`
DOMException: message property
==============================

 The **`message`** read-only property of the
 `DOMException` interface returns a string representing
 a message or description associated with the given error name.

Value
-----

A string.

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

| Specification |
| --- |
| Web IDL Standard # dom-domexception-message |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Accelerometer: z property
=========================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`z`** read-only property of the `Accelerometer` interface returns a number specifying the acceleration of the device along its z-axis.

Value
-----

A `Number`.

Examples
--------

Acceleration is typically read in the `reading` event callback. In the example below this occurs sixty times a second.


```js
const accelerometer = new Accelerometer({ frequency: 60 });

accelerometer.addEventListener("reading", (e) => {
  console.log(`Acceleration along the X-axis ${accelerometer.x}`);
  console.log(`Acceleration along the Y-axis ${accelerometer.y}`);
  console.log(`Acceleration along the Z-axis ${accelerometer.z}`);
});
accelerometer.start();
```

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

| Specification |
| --- |
| Accelerometer # accelerometer-z |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Accelerometer: Accelerometer() constructor
==========================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`Accelerometer()`** constructor creates a new `Accelerometer` object which returns the acceleration of the device along all three axes at the time it is read.

Syntax
------


```js
new Accelerometer()
new Accelerometer(options)
```

### Parameters

`options` Optional

Options are as follows:

`frequency`

The desired number of times per second a sample should be taken, meaning the number of times per second the `reading` event will be called. A whole number or decimal may be used, the latter for frequencies less than a second. The actual reading frequency depends on the device hardware and consequently may be less than requested.

`referenceFrame`

Either `'device'` or `'screen'`. The default is `'device'`.


### Exceptions

`SecurityError` `DOMException`

Use of this feature was blocked by a Permissions Policy.

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

| Specification |
| --- |
| Accelerometer # dom-accelerometer-accelerometer |

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

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

See also
--------

* `reading` event
Accelerometer: y property
=========================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`y`** read-only property of the `Accelerometer` interface returns a number specifying the acceleration of the device along its y-axis.

Value
-----

A `Number`.

Examples
--------

Acceleration is typically read in the `reading` event callback. In the example below this occurs sixty times a second.


```js
const accelerometer = new Accelerometer({ frequency: 60 });

accelerometer.addEventListener("reading", (e) => {
  console.log(`Acceleration along the X-axis ${accelerometer.x}`);
  console.log(`Acceleration along the Y-axis ${accelerometer.y}`);
  console.log(`Acceleration along the Z-axis ${accelerometer.z}`);
});
accelerometer.start();
```

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

| Specification |
| --- |
| Accelerometer # accelerometer-y |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Accelerometer: x property
=========================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`x`** read-only property of the `Accelerometer` interface returns a number specifying the acceleration of the device along its x-axis.

Value
-----

A `Number`.

Examples
--------

Acceleration is typically read in the `reading` event callback. In the example below this occurs sixty times a second.


```js
const accelerometer = new Accelerometer({ frequency: 60 });

accelerometer.addEventListener("reading", (e) => {
  console.log(`Acceleration along the X-axis ${accelerometer.x}`);
  console.log(`Acceleration along the Y-axis ${accelerometer.y}`);
  console.log(`Acceleration along the Z-axis ${accelerometer.z}`);
});
accelerometer.start();
```

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

| Specification |
| --- |
| Accelerometer # accelerometer-x |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioParam: cancelAndHoldAtTime() method
========================================

 The **`cancelAndHoldAtTime()`** method of the
 `AudioParam` interface cancels all scheduled future changes to the
 `AudioParam` but holds its value at a given time until further changes are
 made using other methods.

Syntax
------


```js
cancelAndHoldAtTime(cancelTime)
```

### Parameters

`cancelTime`

 A double representing the time (in seconds) after the `AudioContext` was
 first created after which all scheduled changes will be cancelled.


### Return value

A reference to the `AudioParam` it was called on.

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

| Specification |
| --- |
| Web Audio API # dom-audioparam-cancelandholdattime |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioParam: setValueAtTime() method
===================================

 The `setValueAtTime()` method of the
 `AudioParam` interface schedules an instant change to the
 `AudioParam` value at a precise time, as measured against
 `AudioContext.currentTime`. The new value is given in the value parameter.

Syntax
------


```js
setValueAtTime(value, startTime)
```

### Parameters

`value`

 A floating point number representing the value the AudioParam will change to at the
 given time.


`startTime`

 A double representing the time (in seconds) after the `AudioContext`
 was first created that the change in value will happen. If the time is less than `AudioContext.currentTime`, the change happens immediately. A `TypeError` is thrown if this value is negative.


### Return value

 A reference to this `AudioParam` object. In some browsers older
 implementations of this interface return `undefined`.

Examples
--------

 This simple example features a media element source with two control buttons (see our
 webaudio-examples repo for the source code, or view the example live). When the buttons are pressed, the `currGain` variable is
 incremented/decremented by 0.25, then the `setValueAtTime()` method is used
 to set the gain value equal to `currGain`, one second from now
 (`audioCtx.currentTime + 1`.)


```js
// create audio context
const AudioContext = window.AudioContext || window.webkitAudioContext;
const audioCtx = new AudioContext();

// set basic variables for example
const myAudio = document.querySelector("audio");
const pre = document.querySelector("pre");
const myScript = document.querySelector("script");

pre.innerHTML = myScript.innerHTML;

const targetAtTimePlus = document.querySelector(".set-target-at-time-plus");
const targetAtTimeMinus = document.querySelector(".set-target-at-time-minus");

// Create a MediaElementAudioSourceNode
// Feed the HTMLMediaElement into it
const source = audioCtx.createMediaElementSource(myAudio);

// Create a gain node and set it's gain value to 0.5
const gainNode = audioCtx.createGain();
gainNode.gain.value = 0.5;
let currGain = gainNode.gain.value;

// connect the AudioBufferSourceNode to the gainNode
// and the gainNode to the destination
source.connect(gainNode);
gainNode.connect(audioCtx.destination);

// set buttons to do something onclick
targetAtTimePlus.onclick = () => {
  currGain += 0.25;
  gainNode.gain.setValueAtTime(currGain, audioCtx.currentTime + 1);
};

targetAtTimeMinus.onclick = () => {
  currGain -= 0.25;
  gainNode.gain.setValueAtTime(currGain, audioCtx.currentTime + 1);
};
```

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

| Specification |
| --- |
| Web Audio API # dom-audioparam-setvalueattime |

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

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

See also
--------

* Using the Web Audio API
AudioParam: exponentialRampToValueAtTime() method
=================================================

 The **`exponentialRampToValueAtTime()`** method of the `AudioParam` Interface schedules a gradual exponential change in the value
 of the `AudioParam`. The change starts at the time specified for the
 *previous* event, follows an exponential ramp to the new value given in the
 `value` parameter, and reaches the new value at the time given in the
 `endTime` parameter.


**Note:** Exponential ramps are considered more useful when changing
 frequencies or playback rates than linear ramps because of the way the human ear
 works.


Syntax
------


```js
exponentialRampToValueAtTime(value, endTime)
```

### Parameters

`value`

 A floating point number representing the value the `AudioParam` will ramp
 to by the given time.


`endTime`

 A double representing the exact time (in seconds) after the ramping starts that the
 changing of the value will stop.


### Return value

 A reference to this `AudioParam` object. In some browsers older
 implementations of this interface return `undefined`.

Examples
--------

 In this example, we have a media source with two control buttons (see the audio-param repo for the source code, or view the example live.) When these buttons are pressed, `exponentialRampToValueAtTime()`
 is used to fade the gain value up to 1.0, and down to 0, respectively. This is pretty
 useful for fade in/fade out effects:


```js
// create audio context
const audioCtx = new AudioContext();

// set basic variables for example
const myAudio = document.querySelector("audio");

const expRampPlus = document.querySelector(".exp-ramp-plus");
const expRampMinus = document.querySelector(".exp-ramp-minus");

// Create a MediaElementAudioSourceNode
// Feed the HTMLMediaElement into it
const source = audioCtx.createMediaElementSource(myAudio);

// Create a gain node and set its gain value to 0.5
const gainNode = audioCtx.createGain();

// connect the AudioBufferSourceNode to the gainNode
// and the gainNode to the destination
gainNode.gain.setValueAtTime(0, audioCtx.currentTime);
source.connect(gainNode);
gainNode.connect(audioCtx.destination);

// set buttons to do something onclick
expRampPlus.onclick = () => {
  gainNode.gain.exponentialRampToValueAtTime(1.0, audioCtx.currentTime + 2);
};

expRampMinus.onclick = () => {
  gainNode.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 2);
};
```


**Note:** A value of 0.01 was used for the value to ramp down to in the
 last function rather than 0, as an *invalid or illegal string* error is thrown
 if 0 is used — the value needs to be positive.


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

| Specification |
| --- |
| Web Audio API # dom-audioparam-exponentialramptovalueattime |

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

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

See also
--------

* Using the Web Audio API
AudioParam: minValue property
=============================

 The **`minValue`**
 read-only property of the `AudioParam` interface represents the minimum
 possible value for the parameter's nominal (effective) range.

Value
-----

 A floating-point `Number` indicating the minimum value permitted for the
 parameter's nominal range.

 The default value of `minValue` is the minimum negative single-precision
 floating-point value (-340,282,346,638,528,859,811,704,183,484,516,925,440).

Examples
--------


```js
const audioCtx = new AudioContext();
const gainNode = audioCtx.createGain();
console.log(gainNode.gain.minValue); // -3.4028234663852886e38
```

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

| Specification |
| --- |
| Web Audio API # dom-audioparam-minvalue |

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

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

See also
--------

* `AudioParam.maxValue`
AudioParam: linearRampToValueAtTime() method
============================================

 The `linearRampToValueAtTime()` method of the `AudioParam`
 Interface schedules a gradual linear change in the value of the
 `AudioParam`. The change starts at the time specified for the
 *previous* event, follows a linear ramp to the new value given in the
 `value` parameter, and reaches the new value at the time given in the
 `endTime` parameter.

Syntax
------


```js
linearRampToValueAtTime(value, endTime)
```

### Parameters

`value`

 A floating point number representing the value the `AudioParam` will ramp
 to by the given time.


`endTime`

 A double representing the exact time (in seconds) after the ramping starts that the
 changing of the value will stop.


### Return value

 A reference to this `AudioParam` object. In some browsers older
 implementations of this interface return `undefined`.

Examples
--------

 In this example, we have a media source with two control buttons (see the audio-param repo for the source code, or view the example live.) When these buttons are pressed, `linearRampToValueAtTime()` is
 used to fade the gain value up to 1.0, and down to 0, respectively. This is pretty
 useful for fade in/fade out effects, although `AudioParam.exponentialRampToValueAtTime()` is often said to be a bit more
 natural.


```js
// create audio context
const audioCtx = new AudioContext();

// set basic variables for example
const myAudio = document.querySelector("audio");

const linearRampPlus = document.querySelector(".linear-ramp-plus");
const linearRampMinus = document.querySelector(".linear-ramp-minus");

// Create a MediaElementAudioSourceNode
// Feed the HTMLMediaElement into it
const source = audioCtx.createMediaElementSource(myAudio);

// Create a gain node and set it's gain value to 0.5
const gainNode = audioCtx.createGain();

// connect the AudioBufferSourceNode to the gainNode
// and the gainNode to the destination
gainNode.gain.setValueAtTime(0, audioCtx.currentTime);
source.connect(gainNode);
gainNode.connect(audioCtx.destination);

// set buttons to do something onclick
linearRampPlus.onclick = () => {
  gainNode.gain.linearRampToValueAtTime(1.0, audioCtx.currentTime + 2);
};

linearRampMinus.onclick = () => {
  gainNode.gain.linearRampToValueAtTime(0, audioCtx.currentTime + 2);
};
```

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

| Specification |
| --- |
| Web Audio API # dom-audioparam-linearramptovalueattime |

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

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

See also
--------

* Using the Web Audio API