e01.org

SpeechRecognition: unspokenPunctuation property

Web Speech API

Web Speech API

The **`unspokenPunctuation`** property of the
SpeechRecognition interface specifies whether the speech recognition engine will infer and insert punctuation marks based on the user's natural speech patterns.

## Value

A boolean value.

- If set to `true`, punctuation will be inferred and inserted automatically.
- If set to `false` (the default), no punctuation will be inserted automatically.

## Description

By default, text output by the Web Speech API's speech recognition engine is unpunctuated. To get this text ready for presentation, an additional step is required to add punctuation in appropriate places, for example by manual editing, or using some kind of Natural Language Processing (NLP) model to infer punctuation. Users can help by manually speaking punctuation (for example, stopping to say "comma" or "question mark"), but this still normally requires processing and is inconvenient.

This process can be made much easier by using the `unspokenPunctuation` property. Setting it to `true` causes the speech recognition engine to automatically infer and insert punctuation marks (such as periods, commas, and question marks) based on the user's natural pauses, grammatical structure, and prosody.

For example, speaking the line

"I am hungry [insert pause] and I must eat soon."

would result in the engine outputting

"I am hungry, and I must eat soon."

The output is not always perfect, but it results in text that is much closer to presentation quality than when `unspokenPunctuation` is not used.

## Examples

### Basic usage

The following code creates a new `SpeechRecognition` object instance using the SpeechRecognition() constructor, then specifies that it should infer punctuation marks by setting `unspokenPunctuation` to `true`:

```js
const recognition = new SpeechRecognition();
recognition.unspokenPunctuation = true;
```

See this in action in the [Web Speech API Playground](https://speech.evanliu.com/).

## Specifications

## Browser compatibility

## See also

- [Web Speech API](/docs/Web/API/Web_Speech_API)

source: MDN Web Docs mirror · page

Cite this

"SpeechRecognition: unspokenPunctuation property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/unspokenPunctuation

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·