npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

speech-into-text

v3.2.4

Published

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

Downloads

2,004

Readme

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

  1. Stop Button: An optional stopBtn parameter to stop speech recognition.
  2. Flexible Selectors: Buttons and dropdowns can use selectors like id, class, tag, or a combination (e.g., tag.class, tag#id).
  3. 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.

| Code | Language | Region |
|-----------|----------------------------|-----------------|
| en-US | English | United States |
| ne-NP | Nepali | Nepal |
| en-GB | English | United Kingdom |
| es-ES | Spanish | Spain |
| fr-FR | French | France |
| de-DE | German | Germany |
| hi-IN | Hindi | India |
| ja-JP | Japanese | Japan |
| ko-KR | Korean | Korea |
| zh-CN | Chinese | China |
| pt-PT | Portuguese | Portugal |
| ru-RU | Russian | Russia |
| ar-SA | Arabic | Saudi Arabia |
| it-IT | Italian | Italy |
| tr-TR | Turkish | Turkey |
| pl-PL | Polish | Poland |
| nl-NL | Dutch | Netherlands |
| sv-SE | Swedish | Sweden |
| da-DK | Danish | Denmark |
| cs-CZ | Czech | Czech Republic |
| fi-FI | Finnish | Finland |
| el-GR | Greek | Greece |
| th-TH | Thai | Thailand |
| hu-HU | Hungarian | Hungary |
| ro-RO | Romanian | Romania |
| sk-SK | Slovak | Slovakia |
| hr-HR | Croatian | Croatia |
| bg-BG | Bulgarian | Bulgaria |
| sr-RS | Serbian | Serbia |
| vi-VN | Vietnamese | Vietnam |
| ms-MY | Malay | Malaysia |
| id-ID | Indonesian | Indonesia |
| ta-IN | Tamil | India |
| ml-IN | Malayalam | India |


Example Usage

  1. Select a language via dropdown or predefined code.
  2. Click "Start" to initiate recognition.
  3. Speak, and transcription appears in outPut.
  4. 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! 🚀