Now in google speech to text API i am doing everything i wanted except for stop when i want now i have tried to call function stop(), pause() in the API and eight on of the is not working
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: false,
};// Create a recognize stream
const recognizeStream = client
.streamingRecognize(request)
.on('error', console.error)
.on('data', data =>
process.stdout.write(
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
.recorder({
sampleRateHertz: sampleRateHertz,
threshold: 0,
verbose: false,
recordProgram: 'rec', // Try also "arecord" or "sox"
silence: '10.0',
})
.on('error', console.error).stream()
.pipe(recognizeStream);console.log('Listening, press Ctrl+C to stop.');
and i am using this code now i have tried calling this function like this record.recorder().stop()
witch result is process.kill("SIGNSTP") is not a sign or invalid
and then i have tried recodr.stop()
this say's function is not found
Then tried to put everything inside a class and delete google.TalktoMe()
(this is the function that contain everything) then also i think voice recorder stop working but still google recognizer is running and that find but when it's finally stop for silence it's outputting huge error some time make my app stop working. is there any one who know answer or work around for this one now for 2 days i am scraping in docs also there is nothing in the forums also and there are no reply to comments also really appreciate if there any answers