Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ginixsan opened this issue May 16, 2019 · 12 comments
Open

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

ginixsan opened this issue May 16, 2019 · 12 comments
Assignees

Comments

@ginixsan
Copy link

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?

@evancohen
Copy link
Owner

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!

@ZTiKnl
Copy link

ZTiKnl commented Jul 25, 2019

(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 ;)

@evancohen
Copy link
Owner

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

@ZTiKnl
Copy link

ZTiKnl commented Jul 25, 2019

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

@evancohen
Copy link
Owner

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
Copy link
Owner

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

@ZTiKnl
Copy link

ZTiKnl commented Jul 26, 2019

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"

@ncpleslie
Copy link

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.

@evancohen
Copy link
Owner

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 evancohen self-assigned this Dec 16, 2019
@ncpleslie
Copy link

ncpleslie commented Dec 17, 2019

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

@simon-tannai
Copy link

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

@sdetweil
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants