1.0.5 • Published 4 years ago

transcribe-stt v1.0.5

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

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
1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago