New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

speech-into-text

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

speech-into-text

SpeechToText is a lightweight, multi-language voice-to-text tool for real-time transcription in web apps.

latest
Source
npmnpm
Version
4.0.2
Version published
Weekly downloads
255
-0.78%
Maintainers
0
Weekly downloads
 
Created
Source

SpeechToText NPM Package

SpeechToText is a lightweight, multi-language voice-to-text conversion package designed for seamless integration into web applications. It supports customization, works with both <textarea> and <div>, and can be used via NPM or CDN. Demo

Features

  • Multi-Language Support: Recognizes languages like English, Nepali, Spanish, French, and more.
  • Customizable Controls: Flexible options to start, stop, clear, and copy text.
  • HTML Compatibility: Works with both <textarea> and <div> elements for output.
  • Lightweight & Flexible: Easy to set up and adapt to your project needs.
  • Language Preserve: Selected language remains selected on reload.
  • Versatile Button Selectors: Pass selectors like id, class, or tag for buttons and dropdowns.
  • Clicky Buttons: CSS is integrated to make buttons visually appealing.
  • Listening effect : Add a listening class with CSS animations to the indicator element to visually signal active speech recognition..

Installation

Using NPM

Install the package via NPM:

npm install speech-into-text  

Getting Started

HTML Setup

To use SpeechToText, ensure the following elements are in your HTML:

<div>  
  <!-- Text Output Area -->
  <div class="indicator">
    <textarea id="outPut" placeholder="Start speaking..." rows="5"></textarea>
  </div>
  <!-- works with div or any html tag -->
  <!-- <div id="outPut"></div> -->
  
  <!-- Control Buttons -->
  <button id="startBtn">Start</button>
  <button id="stopBtn">Stop</button> <!-- Optional -->
  <!-- ----Optional Buttons----- -->
  <!-- Language Selector -->
  <select id="langSelection"></select>  
  <button id="clearBtn">Clear</button>
  <button id="copyBtn">Copy</button>
</div>  

Using CDN

Include the package via a CDN if installation is not preferred:

<script type="module" src="script.js"></script>  

Setup

import { speechToText } from 'https://unpkg.com/speech-into-text@latest/index.js';  
speechToText({
 outPut:'#outPut',
 startBtn:'#startBtn',
 langSelection:'#langSelection'// or for specific langanguage use code like langSelection:"ne-NP"
 // other are optional include any of those if required
 stopBtn:'#stopBtn',
 clearBtn:"#clearBtn", 
 copyBtn:"#copyBtn",
 recIndicator:"#indicator", //optional add css to view change on its class "listening"
 });   

Using NPM Package

Initialize the speechToText function with the appropriate selectors:

Setup

import { speechToText } from 'speech-into-text';  
speechToText({
 outPut:'#outPut',
 startBtn:'#startBtn',
 langSelection:'#langSelection',// or for specific langanguage use code like langSelection:"ne-NP"
 // other are optional include any of those if required
 stopBtn:'#stopBtn',
 clearBtn:"#clearBtn", 
 copyBtn:"#copyBtn",
 recIndicator:"#indicator", //optional add css to view change on its class "listening"
 });

Key Updates

  • Stop Button: An optional stopBtn parameter to stop speech recognition.
  • Flexible Selectors: Buttons and dropdowns can use selectors like id, class, tag, or a combination (e.g., tag.class, tag#id).
  • Language Selector: Supports dropdown IDs, classes, or a predefined code list.

Supported Languages

The package supports a wide variety of languages. You can pass the dropdown id/class or directly specify a language code.

CodeLanguageRegion
en-USEnglishUnited States
ne-NPNepaliNepal
en-GBEnglishUnited Kingdom
es-ESSpanishSpain
fr-FRFrenchFrance
de-DEGermanGermany
hi-INHindiIndia
ja-JPJapaneseJapan
ko-KRKoreanKorea
zh-CNChineseChina
pt-PTPortuguesePortugal
ru-RURussianRussia
ar-SAArabicSaudi Arabia
it-ITItalianItaly
tr-TRTurkishTurkey
pl-PLPolishPoland
nl-NLDutchNetherlands
sv-SESwedishSweden
da-DKDanishDenmark
cs-CZCzechCzech Republic
fi-FIFinnishFinland
el-GRGreekGreece
th-THThaiThailand
hu-HUHungarianHungary
ro-RORomanianRomania
sk-SKSlovakSlovakia
hr-HRCroatianCroatia
bg-BGBulgarianBulgaria
sr-RSSerbianSerbia
vi-VNVietnameseVietnam
ms-MYMalayMalaysia
id-IDIndonesianIndonesia
ta-INTamilIndia
ml-INMalayalamIndia

Example Usage

  • Select a language via dropdown or predefined code.
  • Click "Start" to initiate recognition.
  • Speak, and transcription appears in outPut.
  • Optionally use "Stop," "Clear," or "Copy" buttons.

Browser Compatibility

This package relies on the SpeechRecognition API, supported in:

  • Google Chrome
  • Microsoft Edge
  • Other Chromium-based browsers

Note: HTTPS is required for this API.

Developed with ❤️ by Darpan Adhikari.

License

This project is licensed under the Apache-2.0 License.

Elevate your web applications with seamless voice-to-text integration! 🚀

Keywords

speech-to-text

FAQs

Package last updated on 06 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts