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

syllabesjs

v1.0.0

Published

![syllabes.js](logo.png) ========================

Downloads

46

Readme

syllabes.js

syllabes.js is a JavaScript library that can parse multiple types of subtitles or lyrics, so you can use them in your application the same way no matter their file format.

Here's how you could use it :

  • Display subtitles on a video with a custom style
  • Act as a polyfill for browser that doesn't understand WebVTT
  • Scroll the lyrics of a song like a karaoke

Useful links :

syllabes.js is proudly written in TypeScript, and is available under the MIT license.

Installation

Download the library using one of these ways :

Supported file formats

  • Ultrastar (.txt) : Used by a PC karaoke game. Contains song metadata and lyrics for one or two people, with syllable precision.
  • SubRip (.srt) : Simple subtitles format for videos. Contains sentences with optional formatting and on-screen positioning.
  • Sub Station Alpha, Advanced SSA (.ssa, .ass) : Powerful subtitles format for videos. Contains sentences with optional metadata, formatting, styling and on-screen positioning.
  • WebVTT (.vtt) : W3C standard to display subtitles on HTML5 videos. Contains sentences with optional formating, on-screen positioning, multiple voices and syllable precision.

Feature | Ultrastar | SubRip | SSA / ASS | WebVTT --------------------- | :-------: | :----: | :-------: | :----: Sentences | ✔ | ✔ | ✘ | ✔ Syllables | ✔ | - | - | ✘ Metadata | ✔ | - | ✘ | ✘ Multiple tracks | ✔ | - | - | - On-screen positioning | - | ✔ | ✘ | ✘ Voice indicators | - | - | - | ✘ Text formating | - | ✔ | ✘ | ✘ Text styling | - | - | ✘ | ✘

Legend :

  • ✔ : Supported by the format
  • ✘ : Supported by the format but not implemented yet in syllabes.js
  • - : Not supported by the format

Usage

Start by instanciating the library.

var sy = new Syllabes();

Then, call the parse method of the library with the file format and its content.

var parsed = sy.parse('webvtt', '[... file content here ...]');

It also accepts an optional options object to influence the parsing.

var config = {
    syllable_precision: false  
};
var parsed = sy.parse('ultrastar', '[... file content here ...]', config);

Don't forget to check the demonstration page in the demo/ folder.

Output examples

Sentence object taken from the output of a parsed Ultrastar file :

{
    id: 1,
    syllables: [
        {
            start: 15650,
            end: 15950,
            duration: 300,
            pitch: 11,
            text: "Rah!",
            type: "freestyle"
        },
        {
            start: 17350,
            end: 17750,
            duration: 400,
            pitch: 11,
            text: " Ah...",
            type: "freestyle"
        }
    ]
}

Sentence object taken from the output of a parsed SubRip file :

{
    id: 1,
    start: 15650,
    end: 17750,
    duration: 2100,
    text: "Rah! Ah..."
}

The output can also include various metadata if the file format permits it.

Building

  1. Clone the git repository
  2. While in the project repository, execute npm install
  3. Execute gulp watch so it compiles the source code as you edit it
  4. Execute gulp build to build all the source code
  5. Execute gulp minify to make a minifed version of the library

Background

At first, syllabes.js was just a bunch of code written for a school project, where we needed to display a song's lyrics in a karaoke-style (so syllable per syllable).

Seeing that there wasn't viable solutions to parse Ultrastar (an open-source Singstar clone) lyrics files in JavaScript, we decided to make our own parser using the few existing specifications of the format.

Seeing that the code worked quite well, I decided to release it in the wild while making enhancements and other files support easy.