@google-cloud/speech
    Overview
    Reviews
    Code
    Tutorials
    Playground
    Contributors
    Issues
    Documentation
    Chat

@google-cloud/speech

Cloud Speech Client Library for Node.js

3.2.6  •  Updated 6 months ago  •  by googleapis  •  Apache License 2.0

Google Cloud Platform logo

Cloud Speech: Node.js Client

release level npm version codecov

Cloud Speech Client Library for Node.js

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable the Cloud Speech API.
  3. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/speech

Using the client library

async function main() {
  // Imports the Google Cloud client library
  const speech = require('@google-cloud/speech');
  const fs = require('fs');

  // Creates a client
  const client = new speech.SpeechClient();

  // The name of the audio file to transcribe
  const fileName = './resources/audio.raw';

  // Reads a local audio file and converts it to base64
  const file = fs.readFileSync(fileName);
  const audioBytes = file.toString('base64');

  // The audio file's encoding, sample rate in hertz, and BCP-47 language code
  const audio = {
    content: audioBytes,
  };
  const config = {
    encoding: 'LINEAR16',
    sampleRateHertz: 16000,
    languageCode: 'en-US',
  };
  const request = {
    audio: audio,
    config: config,
  };

  // Detects speech in the audio file
  const [response] = await client.recognize(request);
  const transcription = response.results
    .map(result => result.alternatives[0].transcript)
    .join('\n');
  console.log(`Transcription: ${transcription}`);
}
main().catch(console.error);

Samples

Samples are in the samples/ directory. The samples’ README.md has instructions for running the samples.

Sample Source Code Try it
Microphone Stream source code Open in Cloud Shell
Beta Features source code Open in Cloud Shell
Infinite Streaming source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell
Recognize source code Open in Cloud Shell
Recognize.v1p1beta1 source code Open in Cloud Shell

The Cloud Speech Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

Popularity

Weekly Downloads
19.6K
Stars
398

Maintenance

Development

Last ver 6 months ago
Created 3 years ago
Last commit 2 months ago
3 days between commits

Technology

Node version: 8.16.0
600.5K unpacked

Compliance

Apache License 2.0
OSI Approved
0 vulnerabilities

Contributors

46 contributors
Justin Beckwith
49 commits, 161 merges, 50 PRs
Works at Google
Alexander Fenster
Maintainer, 27 commits, 29 merges, 28 PRs
Yoshi Automation Bot
47 commits, 3 merges, 81 PRs
Works at googleapis
renovate[bot]
49 commits
Benjamin E. Coe
Maintainer, 20 commits, 26 merges, 20 PRs
Works at Google
Stephen Sawchuk
21 commits, 21 merges, 5 PRs

Tags

google apis client
google api client
google apis
google api
google
google cloud platform
google cloud
cloud
google speech
speech
Google Cloud Speech API
Ready for the next level?
Join Openbase's founding team to help us build the ultimate open-source app store, work with the latest technologies, and enjoy great culture, impact and autonomy
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookLinkedIn
© 2020 Devstore, Inc.