sonus icon indicating copy to clipboard operation
sonus copied to clipboard

Sonus.pause(sonus) and Sonus.resume(sonus)

Open ginixsan opened this issue 5 years ago • 12 comments

I've read previous issues but haven't been able to get anything clear.When I try to pause or resume sonus with Sonus.pause(sonus). I get this error.

Sonus.pause = () => record.pause() ^

TypeError: record.pause is not a function

I've tried too stoping it and restarting it but then I get the

throw er; // Unhandled 'error' event ^

Error: write after end

That I saw some people get too. Anybody was able to get any workaround to pause sonus and resume it?

ginixsan avatar May 16 '19 23:05 ginixsan

Just took a quick look at this, looks like this is a bug that was introduced in the most recent version. I'll take a stab at fixing it this weekend and publishing a fix. Thanks for reporting this!

evancohen avatar May 23 '19 22:05 evancohen

(node:3503) UnhandledPromiseRejectionWarning: TypeError: record.pause is not a function
    at Writable.sonus.pause (/home/ztik/nodejs/sara/node_modules/sonus/index.js:141:12)

Seems like it is still ongoing (for me at least)...

A solution/workaround would be appreciated, but personally I am not in any hurry ;)

ZTiKnl avatar Jul 25 '19 19:07 ZTiKnl

Oof, this fell off my radar, sorry! Will attempt to fix asap.

evancohen avatar Jul 25 '19 20:07 evancohen

No need to apologize, instead I should say thanks for this wonderful module. It is a core function of my app, without it I'd have no app at all ;) (I also included a link to sonus in the credits of my app)

P.S. feel free to ask for more information if you need any

ZTiKnl avatar Jul 25 '19 23:07 ZTiKnl

Immediate solution is to comment out https://github.com/evancohen/sonus/blob/master/index.js#L140-L146 in your node_modules folder. It seems that at some point pause and resume was removed from the underlying audio library.

They just pushed a new version of that library that supports this functionality, so I'm going to go ahead and update everything to use that instead.

evancohen avatar Jul 26 '19 03:07 evancohen

So I have a working version with the new recording library, but it didn't match well with the current implementation. I'm not thrilled with the results. I'm going to do a refactor, but I've pushed the changes as-is to the pause-resume branch and published a release candidate on npm: [email protected]

To use this version just

npm install sonus@next

evancohen avatar Jul 26 '19 05:07 evancohen

I have just ran npm uninstall sonus and npm install sonus@next. package.json seems to confirm this:

  "dependencies": {
    "sonus": "^1.0.4-rc1",

However, I am still receiving the same error as before:

(node:3436) UnhandledPromiseRejectionWarning: TypeError: record.pause is not a function
    at Object.Sonus.pause (/home/ztik/nodejs/sara/node_modules/sonus/index.js:204:28)
    at Object.pause (/home/ztik/nodejs/sara/hearing.js:63:11)

Is it possible that some dependency requires separate updating? (I'm new to javascript/nodejs, so it is quite possible that I'm wrong/misunderstanding)

edit: package.json in ./node_modules/sonus also tells me I'm using rc1: "version": "1.0.4-rc1"

ZTiKnl avatar Jul 26 '19 19:07 ZTiKnl

Any update on this?

It seems that the "node-record-lpcm16" version used by Sonus ("^0.3.1") doesn't support Pause/Resume until version "1.0.0". Attempted to rectify the issue by using "npm install sonus@next" but was unsuccessful.

ncpleslie avatar Dec 16 '19 21:12 ncpleslie

I won't be able to look at this until over the holidays, but hopefully I can figure something out on vacation next week.

evancohen avatar Dec 16 '19 22:12 evancohen

I gave it a go and managed to have some success. I tested it on a Raspberry Pi and it seemed to be working.

https://github.com/ncpleslie/sonus

ncpleslie avatar Dec 17 '19 03:12 ncpleslie

Hi ! I'm trying to use .pause() and .resume() but I got this error: INVALID_INDEX.

simon-tannai avatar Feb 06 '20 22:02 simon-tannai

I've created a socket.io mechanism to talk the background sonus process to allow it to reliquish the microphone. also added mechanism to use the existing plugins the get audio back from secondary recording

for alex and google assistant, think of the multi-turn dialog for creating a calendar entry

sdetweil avatar Mar 26 '21 20:03 sdetweil