AskHandle

AskHandle Blog

Does the browser have a built-in speech-to-text feature?

June 20, 2025Emily Henderson3 min read
  • Speech-to-text
  • Browser

Does the browser have a built-in speech-to-text feature?

Many users wonder whether modern web browsers have a built-in speech-to-text feature they can access and use in their own web projects. The good news is that most popular browsers do support speech recognition technology, which allows users to convert spoken words into text directly within a web application. This article explains how this feature works and provides simple code examples to help you integrate speech-to-text into your websites.

What is speech-to-text in browsers?

Speech-to-text in browsers refers to the ability of web applications to recognize spoken language and convert it into written text. This functionality is achieved through the browser’s support for the Speech Recognition API, a web standard that enables real-time voice recognition.

Most modern browsers like Google Chrome, Microsoft Edge, and Opera support the Speech Recognition API. However, support may vary across browsers, and not all browsers implement the API in the same way. Currently, the API is most fully supported in Chrome, with limited support in other browsers.

How to use speech recognition in web browsers

Using speech recognition on your website involves working with the Web Speech API, which provides the SpeechRecognition interface. Here are the basic steps:

1. Check for browser support

Before using the API, you should verify whether the user's browser supports it.

javascript
1const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
2
3if (!SpeechRecognition) {
4  alert("Sorry, your browser does not support speech recognition.");
5}

2. Create a SpeechRecognition object

If supported, create an instance of the SpeechRecognition interface.

javascript
1const recognition = new SpeechRecognition();
2recognition.continuous = false; // Stop recognition after one phrase
3recognition.lang = 'en-US'; // Set language
4recognition.interimResults = true; // Show partial results

3. Add event handlers

Set up functions to handle events like when recognition starts, results are received, or errors occur.

javascript
1recognition.onresult = function(event) {
2  let transcript = '';
3  for (let i = event.resultIndex; i < event.results.length; ++i) {
4    transcript += event.results[i].transcript;
5  }
6  console.log("Recognized speech: ", transcript);
7};
8
9recognition.onerror = function(event) {
10  console.error("Error occurred in recognition: ", event.error);
11};

4. Start recognition

You can start the process with a simple call.

javascript
1recognition.start();

5. Stop recognition

To stop listening, call:

javascript
1recognition.stop();

Example: Basic speech-to-text implementation

Here's a simple example combining all the steps above:

html
1<button id="startBtn">Start Recording</button>
2<button id="stopBtn">Stop Recording</button>
3<div id="output"></div>
4
5<script>
6  const startBtn = document.getElementById('startBtn');
7  const stopBtn = document.getElementById('stopBtn');
8  const outputDiv = document.getElementById('output');
9
10  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
11
12  if (!SpeechRecognition) {
13    alert("Your browser does not support Speech Recognition API.");
14  } else {
15    const recognition = new SpeechRecognition();
16    recognition.continuous = false;
17    recognition.interimResults = true;
18    recognition.lang = 'en-US';
19
20    recognition.onresult = function(event) {
21      let transcript = '';
22      for (let i = event.resultIndex; i < event.results.length; ++i) {
23        transcript += event.results[i].transcript;
24      }
25      outputDiv.innerText = transcript;
26    };
27
28    recognition.onerror = function(event) {
29      console.error("Recognition error:", event.error);
30    };
31
32    startBtn.onclick = () => recognition.start();
33    stopBtn.onclick = () => recognition.stop();
34  }
35</script>

This code provides two buttons: one to start listening and another to stop. The recognized speech appears in a div element.

Limitations to keep in mind

While the Speech Recognition API can be very useful, it has some limitations:

  • Browser support is mainly in Chrome. Support in other browsers is limited or absent.
  • The API depends on an internet connection for most implementations.
  • It may not handle very noisy environments well.
  • The recognition accuracy depends on pronunciation, clarity, and language settings.

Most modern browsers, especially Chrome, have a built-in speech-to-text feature through the Web Speech API. Developers can add voice recognition to their websites with relatively simple JavaScript code, enabling users to input text through speech easily. Remember to check browser compatibility before implementation, and test thoroughly to ensure a smooth user experience.