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

read-aloud-component

v1.0.3

Published

"Just Read Out" - A Simple, Powerful Way to Bring Voice to Your Content!

Downloads

202

Readme

🎙️ Read Aloud Web Component

"Just Read Out" – A Simple, Powerful Way to Bring Voice to Your Content!

Demo for read out

Overview

The Read Aloud Web Component is a customizable, lightweight solution that allows you to add text-to-speech functionality to any webpage. With built-in support for the Web Speech API, it provides a seamless reading experience, highlighting words as they are read aloud.

LAUNCH DEMO


✨ Features

  • 🎤 Web Speech API Integration: Uses the browser's native speech recognition capabilities.
  • 📝 Customizable Text: Style your text any way you like—functionality stays intact.
  • 🌍 Language Flexibility: Set the speech language through a simple lang attribute.
  • 🔍 Live Word Highlighting: Automatically highlights the current word being read.
  • 🌐 Cross-Browser Compatibility: Works in browsers that support the Web Speech API (Chrome, Safari, Edge, etc.).

🚀 How to Use

  1. Add the custom component to your HTML:

    <read-aloud-component lang="en-US">
      <p slot="paragraph">The quick brown fox jumps over the lazy dog.</p>
      <button slot="start-btn">Start Reading</button>
    </read-aloud-component>
  2. Style the component (paragraph and button) with CSS as desired.

    read-aloud-component {
      display: block;
      margin: 20px 0;
    }
    
    read-aloud-component p {
      font-size: 1.2em;
      color: #333;
    }
    
    read-aloud-component button {
      background-color: #007bff;
      color: white;
      border: none;
      border-radius: 5px;
      padding: 10px 15px;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }
    
    read-aloud-component button:hover {
      background-color: #0056b3;
    }
  3. Start the reading session! Click "Start Reading," and the text will be read aloud while highlighting each word.


📋 Attributes and Methods

| Attribute | Type | Description | Default Value | | ----------- | ------- | ----------------------------------------------------------- | ------------- | | lang | String | Defines the language for speech recognition (en-US, etc.) | en-US | | highlight | Boolean | Enables/disables live word highlighting | true | | voice | String | Selects the voice for speech output (native browser voices) | default | | rate | Number | Controls the speech speed (0.1 - 10) | 1 |

Available Methods

| Method | Description | Usage Example | | ----------------- | ------------------------------------- | ------------------------- | | startReading() | Starts reading the content aloud. | element.startReading() | | stopReading() | Stops the current reading session. | element.stopReading() | | pauseReading() | Pauses the speech temporarily. | element.pauseReading() | | resumeReading() | Resumes speech from the paused point. | element.resumeReading() |


🎯 Example Usage

<read-aloud-component lang="en-GB" highlight="true" rate="1.2">
  <p slot="paragraph">
    A journey of a thousand miles begins with a single step.
  </p>
  <button slot="start-btn">Read Aloud</button>
</read-aloud-component>

With this example:

  • The text is read in British English (en-GB).
  • Word highlighting is enabled.
  • The reading speed is slightly faster than normal (rate="1.2").

🛠️ Installation

  1. Include the JavaScript file in your project:

    <script src="app.js"></script>

    OR USE unpkg

    <script src="https://unpkg.com/[email protected]/app.js"></script>

You're ready to go! Simply add the component to your HTML and style it.

NPM LINK

Use Cases

  • 🌍 Language Learning
    Helps learners follow along as each word is highlighted during speech, improving comprehension and pronunciation.

  • 👩‍🏫 Educational Tool
    Teachers can use it on smartboards to guide students through reading, making lessons more interactive.

  • 👶 Reading Practice for Kids
    Parents can add custom sentences or stories to aid children in reading development with real-time word tracking.

  • 🗣️ Speech Development
    Learners can improve fluency by listening to text read aloud while following the highlighted words.

  • Accessibility
    Assists individuals with reading challenges by highlighting spoken words, enhancing focus and reducing cognitive load.

EXAMPLE USING YOUR OWN TEXT

💻 Browser Support

Works on all major browsers with Web Speech API support:

  • Google Chrome
  • Safari
  • Microsoft Edge

Enhance the accessibility of your website by making it more engaging and easier to use with the Read Aloud Web Component! 😃