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

@dinuda/transcript-tracer

v1.0.0

Published

a tool that synchronizes text transcripts with corresponding audio segments using WebVTT (VTT) files

Downloads

79

Readme

Transcript Tracer

Transcript Tracer is a tool that synchronizes text transcripts with audio or video content using WebVTT (VTT) files. By linking the transcript to specific timestamps, it allows users to follow along with the media playback and highlights the corresponding transcript text. This tool is designed to enhance accessibility and user engagement.

Features

  • Transcript and Media Synchronization: Automatically syncs text transcripts with audio or video playback.
  • Customizable Options: Offers configuration options for clickability, auto-scrolling, and time offset.
  • WebVTT Support: Supports VTT files for captioning and synchronization.
  • Interactive Transcripts: Users can click on any part of the transcript to jump to the corresponding audio or video segment.

Demo - (Custom styled)

https://github.com/user-attachments/assets/803117de-025f-468f-a1a1-243939618188

Demo raw

Demo

Installation

You can install Transcript Tracer using npm:

npm install transcript-tracer

Usage

Here’s a simple example to get you started:

1. HTML Setup

Include an audio or video element with a WebVTT file:

<audio
  src="https://raw.githubusercontent.com/Dinuda/transcript-tracer/master/src/assets/test.wav"
  controls
>
  <track
    kind="metadata"
    src="https://raw.githubusercontent.com/Dinuda/transcript-tracer/master/src/assets/test.vtt"
  />
</audio>

<div
  class="tt-transcript"
  data-tt-media-urls="https://raw.githubusercontent.com/Dinuda/transcript-tracer/master/src/assets/test.wav"
>
  Welcome to the transcript tracer test. In this demo, we will synchronize the
  transcript with the audio. You can generate wav or mp3 files and VTT captions
  using the Azure Speech Service. Let's get started.
</div>

2. Initialize Transcript Tracer in JavaScript

import { loadTranscriptTracer } from "transcript-tracer";

// Fetch the transcript and initialize
fetch(
  "https://raw.githubusercontent.com/Dinuda/transcript-tracer/master/src/assets/test.vtt"
)
  .then(
    (response) => response.text() // Get the transcript as text
  )
  .then((transcript) => {
    // Once the transcript is fetched, initialize the TranscriptTracer
    TranscriptTracer.loadTranscriptTracer({}, transcript);
  })
  .catch((error) => console.error("Error loading the transcript:", error));

You can also use cleanupTranscriptTracer() to reset the state when needed.

Configuration Options

Transcript Tracer provides several configuration options for customization:

| Option | Type | Description | | -------------------- | --------- | ------------------------------------------------------------------------------- | | blockSelector | string | CSS selector for block elements within the transcript. | | phraseSelector | string | CSS selector for phrase elements within the transcript. | | alignmentFuzziness | number | Amount of fuzziness allowed when aligning words with timings (default: 0). | | timeOffset | number | Time offset to adjust the current time of the media player (default: 0). | | autoScroll | string | Determines the scroll behavior: 'block', 'phrase', or 'word' (default: null). | | clickable | boolean | Whether words should be clickable to jump to their start time (default: false). |

Example with Options:

loadTranscriptTracer(
  {
    ttClickable: true,
    ttAutoScroll: "word", // Auto-scroll by 'block', 'phrase', or 'word'
    ttTimeOffset: 0.5, // Adjust timing offset in seconds
  },
  transcript
);

Styling

You can customize the look and feel of the transcript using CSS. Here’s an example of some basic styles:

.tt-transcript {
  font-family: Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.tt-word {
  cursor: pointer;
  background-color: transparent;
  transition: background-color 0.3s ease;
}

.tt-word:hover {
  background-color: #f0f0f0;
}

.tt-current-word {
  background-color: #ffeb3b;
}

.tt-previous-word {
  color: gray;
}

.tt-current-block-container,
.tt-current-phrase-container {
  background-color: rgba(255, 235, 59, 0.3);
}

Feel free to modify the styles to fit your project’s design.

Roadmap

  • React docs
  • Add support for subtitles with multiple languages.
  • Integration with popular video platforms.
  • Improved performance and scalability for larger transcripts.
  • Browser extensions for easier integration with websites.

License

This project is licensed under the MIT License - see the LICENSE file for details.