GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Audio Stream Timing Out Instantly · Issue #626 · GoogleCloudPlatform/nodejs-docs-samples

Audio Stream Timing Out Instantly #626

New issue
Copy link
New issue
Copy link
Closed
Closed
Audio Stream Timing Out Instantly#626
Copy link

Description

@dhanud5
dhanud5
opened on May 27, 2018
Issue body actions

So I'm trying to get Google speech to text to listen to my microphone for transcription. I am using windows and sox. System variable path is set and all google cloud accounts are active. My problem is that the service stops right as it starts. The max amount of time it ran for was around 50ms. Here's a screencap of what I get in the command prompt.
image

Here's my code:

const express = require('express');
const app = express();
const http = require('http');
const server = require('http').createServer(app);
var io = require('socket.io')(server);

const fs = require('fs');

const LISTEN_PORT = 8080;

var transText;

server.listen(LISTEN_PORT);
app.use(express.static(__dirname + '/public'));

console.log("Listening on port: " + LISTEN_PORT);

app.get( '/', function( req, res ){
res.sendFile( __dirname + '/public/index.html' );
});

//////////////////////////////////////////////////////////////////////

// Creates a client
const record = require('node-record-lpcm16');

// Imports the Google Cloud client library
const speech = require('@google-cloud/speech');

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

const encoding = 'LINEAR16';
const sampleRateHertz = 16000;
const languageCode = 'en-US';

const request = {
config: {
encoding: encoding,
sampleRateHertz: sampleRateHertz,
languageCode: languageCode,
},
interimResults: true, // If you want interim results, set this to true
};

// Create a recognize stream
const recognizeStream = client
.streamingRecognize(request)
.on('error', console.error)
.on('data', data =>
console.log(
data.results[0] && data.results[0].alternatives[0]
? Transcription: ${data.results[0].alternatives[0].transcript}\n
: \n\nReached transcription time limit, press Ctrl+C\n
)
);

// Start recording and send the microphone input to the Speech API
record
.start({
sampleRateHertz: 16000,
// Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
verbose: true,
recordProgram: 'sox', // Try also "arecord" or "sox"
silence: '1500000.0',
device: 'plughw:0,0',
})
.on('error', console.error)
.pipe(recognizeStream);

setTimeout(function () {
record.stop()
}, 10000)

console.log('Listening, press Ctrl+C to stop.');

//////////////////////////////////////////////////////////////////////////
io.on('connection', function(socket) {

    io.emit('transcription', transText);

});

Activity

  1. fhinkel commented on Nov 8, 2018

    @fhinkel
    fhinkel
    on Nov 8, 2018
    Contributor
    More actions

    @dhanud5 sorry for the late response. If this is still an issue, please file it here.

  2. fhinkel
    closed this as completedon Nov 8, 2018
  3. grayside
    added a commit that references this issue on Oct 26, 2022

    chore(main): release 3.0.0 (#626)

    bf5288a
  4. grayside
    added a commit that references this issue on Nov 3, 2022

    chore(main): release 3.0.0 (#626)

    e668298
  5. ahrarmonsur
    added 5 commits that reference this issue on Nov 16, 2022

    chore(main): release 4.0.0 (#626)

    3496701

    chore(main): release 4.0.0 (#626)

    6a94c24

    chore(main): release 4.0.0 (#626)

    ad6c45f

    chore(main): release 4.0.0 (#626)

    a749a74

    chore(main): release 4.0.0 (#626)

    1252ff2
  6. ace-n
    added 6 commits that reference this issue on Nov 17, 2022

    chore: Refactor translate samples (#626)

    2d767a7

    chore: Refactor translate samples (#626)

    9621e48

    chore(main): release 4.0.0 (#626)

    e60c13a

    chore: Refactor translate samples (#626)

    6c426a9

    chore: Refactor translate samples (#626)

    d7849d1

    chore: Refactor translate samples (#626)

    039471a
  7. kweinmeister
    added a commit that references this issue on Nov 18, 2022

    chore(main): release 4.0.3 (#626)

    f3b45d1
  8. NimJay
    added 2 commits that reference this issue on Nov 19, 2022

    chore(main): release 4.1.0 (#600)

    db5ff7a

    chore(main): release 4.1.0 (#600)

    9b44a58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.