Closed onlyspike closed 5 years ago
Guessing the Google cloud speech (gRPC) library that Sonus depends on has been Depreciated (or will be soon). I'll see if I can update the library this weekend. This will require some code changes on your part after updating.
Made any progress on this?
I made some progress locally for this, but there are still a few kinks that I haven't had the time to iron out. I'm on my way to Bali and should have some quality beach coding time to finish it up.
Ok, I managed to get this working on the dev
branch and published a prerelease version on npm. Can you give this a shot? Note the change in authentication.
If you're using Sonus directly you can checkout the dev
branch directly, or if you're consuming it in another project you can npm install sonus@0.2.0-rc1
Hi.
Thank you for the update, however I am still having an issue. I have updated my script. When I run my script the the script outputs :
"Say "sonus"..."
and then exits.
Below is my code.
const Sonus = require('sonus')
const speech = require('@google-cloud/speech')
const client = new speech.SpeechClient({
projectId: 'myprojid-123456',
keyFilename: 'key.json'
})
const hotwords = [{ file: 'sonus.pmdl', hotword: 'sonus' }]
const language = "en-US"
//recordProgram can also be 'arecord' which works much better on the Pi and low power devices
const sonus = Sonus.init({ hotwords, language, recordProgram: "arecord" }, client)
Sonus.start(sonus)
console.log('Say "' + hotwords[0].hotword + '"...')
sonus.on('hotword', (index, keyword) => console.log("!" + keyword))
sonus.on('partial-result', result => console.log("Partial", result))
sonus.on('error', error => console.log('error', error))
sonus.on('final-result', result => {
console.log("Final", result)
if (result.includes("stop")) {
Sonus.stop()
}
})
The bad news is that your microphone isn't correctly configured, the good news is that Sonus is working as intended and your microphone issue should be easy to fix. Check out the Initialization docs, you may need to specify a recording device, eg: "hw:1,0"
Thank you for your quick response.. I tried that setting and tested the microphone with the blow command and it is recording.
arecord --device=hw:1,0 --format S16_LE --rate 44100 -c1 test.wav
Yet, it still does the same thing. Not sure if it may be my cheap microphone or something.
This may sound silly, but you may want to try restarting. If that doesn't work, you should try using Sox/rec (instructions in the README) - there's a little bit of input lag, but it would at least get you started while you figure out what's going on with your mic.
Apologies for only responding now. I finally received my ReSpeaker. After testing it out on my Raspberry Pi that it was working I ran my script again and at first it didnt work. I then changed the code back the the below and it worked as expected.
const sonus = Sonus.init({ hotwords, language, recordProgram: "rec",device:"hw:1,0" }, client)
It didnt work with arecord at first so changed it back to rec and it then worked.
Must have been my crappy mic.
Thanks for all your help.
I just published a fix in the latest version of Sonus, can you give that a try and see if it fixes your issue? Either way, it looks like this issue has been solved :)
Hi, I installed as described into a new project.
I used the example file to adapt my index file but when I run my file i get the below output
Say "sonus"... (node:6174) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
Below is my index.js file
'use strict'
const ROOT_DIR = __dirname + '/../' const Sonus = require('sonus') const speech = require('@google-cloud/speech')({ projectId: 'myprojid-123456', keyFilename: 'key.json' })
const hotwords = [{ file: 'sonus.pmdl', hotword: 'sonus' }] const language = "en-US"
//recordProgram can also be 'arecord' which works much better on the Pi and low power devices const sonus = Sonus.init({ hotwords, language, recordProgram: "arecord" }, speech)
Sonus.start(sonus) console.log('Say "' + hotwords[0].hotword + '"...')
sonus.on('hotword', (index, keyword) => console.log("!" + keyword))
sonus.on('partial-result', result => console.log("Partial", result))
sonus.on('error', error => console.log('error', error))
sonus.on('final-result', result => { console.log("Final", result) if (result.includes("stop")) { Sonus.stop() } })