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

transcribe-stt

v1.0.5

Published

Transcribe audio of any length using Google's Speech to Text API

Downloads

3

Readme

Logo

transcribe-stt

NPM version Github version

Transcribe audio of any length using Google's Speech to Text API

Contents

Description

Transcribe audio of any length using Google's Speech to Text API with its Node client

Installation

npm i transcribe-stt

Reference

See the reference documentation

Google authentication

To stream any audio, you must authenticate yourself with Google. To do this, just follow the steps below

  1. Complete step 1 (only) of Google's "quickstart" guide to create a GCP project and a private key. Save the private key in your project. (In this guide, we will call it key.json)

  2. Make sure any repo utilities ignore your new JSON key, e.g. by adding it to a .gitignore:

    key.json
  3. Change the value of the environment variable GOOGLE_APPLICATION_CREDENTIALS to the absolute path to your JSON key. There are multiple ways to do this. The easiest way is probably directly through Node

    • Directly through Node

      1. Before using any transcribe-stt services, define the environment variable

        import { resolve } from "path";
        // Or in JavaScript: const { resolve } = require("path");
        
        const filename = resolve(__dirname, "./key.json");
        process.env.GOOGLE_APPLICATION_CREDENTIALS = filename;

        Define the relative path relative to the directory that the script is in.

      2. Done!

    • dotenv (a package for easily defining environment variables)

      1. Create a file called .env and add it to any .gitignore/etc in the same way as the JSON key

      2. In your .env, add a line as follows, replacing PATH with the absolute path to your JSON key

        GOOGLE_APPLICATION_CREDENTIALS=PATH
      3. Install dotenv

        npm i dotenv --save-dev
      4. Configure dotenv before using any transcribe-stt services

        import { config } from "dotenv";
        // Or in JavaScript: const { config } = require("dotenv");
        
        config();
      5. Done!

    • Command-line/shell

      1. Define environment variable, replacing PATH with the absolute path to your JSON key
        • Linux/macOS
          export GOOGLE_APPLICATION_CREDENTIALS="PATH"
        • Windows
          • PowerShell
            $env:GOOGLE_APPLICATION_CREDENTIALS="PATH"
          • Command prompt
            set GOOGLE_APPLICATION_CREDENTIALS=PATH
      2. Done!

Converting audio to WAV file

To use an audio file with transcribe-stt, it must be a WAV file with mono audio. This is a simple guide to converting audio files with an editor, specifically Audacity which is free and available on all 3 major operating systems. However, many of the steps will be very similar on any audio editing software

  1. Open the editor and import your audio

    File > Import > Audio...

  2. Select all

    Select > All

  3. Convert to mono if necessary

    Tracks > Mix > Mix Stereo Down to Mono

  4. Optionally check or change the sample rate (and remember it for later)

    Tracks > Resample...

  5. Export as WAV file

    Export > Export as WAV

  6. Optionally change the encoding. When the export dialogue appears, there is an option to "Save as type" where you can choose what encoding you want (and remember it for later). Learn more about encodings below

To do

  • Use docker
  • Document how to change to a WAV file programmatically
  • Allow advanced configuration options documented here
  • Add data event for DistributedSTTStream