大网数据广告活动
Web 标准与前端开发

SpeechRecognition: unspokenPunctuation property

· 52CE 我爱测

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.

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.SpeechRecognition constructor, then specifies that it should infer punctuation marks by setting unspokenPunctuation to true:

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

See this in action in the Web Speech API Playground.

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。