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 🙏

© 2025 – Pkg Stats / Ryan Hefner

supernal-tts-widget

v1.1.1

Published

Embeddable TTS widget for blogs and websites

Readme

supernal-tts-widget

Embeddable Text-to-Speech widget for blogs and websites.

Installation

npm install supernal-tts-widget

Quick Start

React/Next.js

import { useEffect } from 'react';
import 'supernal-tts-widget/widget.css';

export default function MyComponent() {
  useEffect(() => {
    import('supernal-tts-widget/widget.js')
      .then(({ SupernalTTS }) => {
        SupernalTTS.init({
          apiUrl: 'https://tts.supernal.ai',
          provider: 'openai',
          voice: 'alloy'
        });
      });
  }, []);

  return (
    <div className="tts-widget" data-text="This text will be read aloud!">
      <p>This text will be read aloud!</p>
    </div>
  );
}

HTML/Static Sites

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://unpkg.com/supernal-tts-widget/widget.css">
</head>
<body>
  <div class="tts-widget" data-text="This content can be read aloud!">
    <p>This content can be read aloud!</p>
  </div>
  
  <script type="module">
    import { SupernalTTS } from 'https://unpkg.com/supernal-tts-widget/widget.js';
    SupernalTTS.init({
      apiUrl: 'https://tts.supernal.ai',
      provider: 'openai',
      voice: 'alloy'
    });
  </script>
</body>
</html>

Configuration

SupernalTTS.init({
  apiUrl: 'https://tts.supernal.ai',  // Required: API endpoint
  provider: 'openai',                  // Optional: TTS provider (default: 'openai')
  voice: 'alloy',                      // Optional: Voice selection
  speed: 1.0,                          // Optional: Playback speed (0.25-4.0)
  apiKey: 'your-api-key',             // Optional: For authenticated requests
  devMode: false,                      // Optional: Enable dev mode features
  clientSideSpeed: true                // Optional: Use browser pitch-preserving time-stretching (default: true)
                                       //           Saves generation costs! Set to false for server-side regeneration
});

Client-Side Speed Adjustment

By default (clientSideSpeed: true), the widget uses the browser's native preservesPitch feature with playbackRate to adjust speed instantly without regenerating audio. This:

  • Saves significant costs - no need to generate audio at multiple speeds
  • Instant speed changes - no loading/regeneration delay
  • Maintains pitch quality - uses browser's time-stretching algorithm
  • ✅ Works with already-cached audio

Set clientSideSpeed: false if you need server-side speed generation with provider-specific pitch correction (more expensive but may have slightly different quality characteristics for extreme speed changes).

Widget Data Attributes

<!-- Custom voice per widget -->
<div class="tts-widget" 
     data-text="Professional voice example" 
     data-voice="coral" 
     data-provider="openai">
  Professional voice example
</div>

<!-- Custom speed -->
<div class="tts-widget" 
     data-text="Fast speech" 
     data-speed="1.5">
  Fast speech
</div>

Available Voices

OpenAI

  • alloy, echo, fable, onyx, nova, shimmer, coral, sage, verse

Mock (Testing)

  • mock-voice-1, mock-voice-2, mock-voice-3

Documentation

Full documentation: https://tts.supernal.ai


Development

This is the SOURCE OF TRUTH for the Supernal TTS widget. All changes should be made here.

Directory Structure

packages/supernal-tts-widget/
├── src/
│   ├── widget.ts    # TypeScript source (EDIT THIS)
│   └── widget.css   # Styles
├── dist/            # Built output (DO NOT EDIT)
│   ├── widget.js    # Bundled JavaScript
│   ├── widget.css   # Copied styles
│   └── widget.d.ts  # TypeScript declarations
├── package.json
└── tsconfig.json

Build Process

  1. Build the widget:

    npm run build

    This runs:

    • tsc - Compiles TypeScript to JavaScript
    • esbuild - Bundles and minifies to a single IIFE file
    • cp - Copies CSS to dist
  2. From monorepo root:

    npm run build:widget
  3. Docs site automatically copies widget on build/start:

    cd docs-site
    npm run copy-widget  # or `npm start` / `npm run build`

Features

  • TypeScript: Proper typing and IDE support
  • Dev Mode Cache Clear: Red button in dev mode to clear local cache
  • Absolute URLs: Handles both relative and absolute audio URLs
  • Branding: Optional Supernal AI badge
  • Responsive: Mobile-friendly design
  • Dark Mode: Automatic dark mode support

Usage in Docs Site

The docs-site imports the widget from this package via:

  • Build script: copy-widget in docs-site/package.json copies built files to static/
  • Component: TTSWidget in docs-site/src/components/TTSWidget/ loads from /js/widget.js

DO NOT edit files in docs-site/static/js/ or docs-site/static/css/ directly!

Making Changes

  1. Edit src/widget.ts or src/widget.css
  2. Run npm run build (or npm run dev for watch mode)
  3. Test in docs-site: cd ../../../docs-site && npm start
  4. The widget will be automatically copied and loaded

Publishing

When ready to publish to npm:

npm version patch|minor|major
npm publish

Integration

See the main README and docs-site for integration examples.