Rei-x / discord-speech-recognition

Speech to text extension for discord.js
https://npmjs.com/package/discord-speech-recognition
MIT License
57 stars 23 forks source link

Opus Error hadn't been handle correctly #11

Closed emthy0 closed 3 years ago

emthy0 commented 3 years ago

I found these errors on @discord/opus when speaking from a web browser which the error hasn't been handle correctly, so it will crash the whole app.

events.js:292
      throw er; // Unhandled 'error' event
      ^

TypeError: The compressed data passed is corrupted
    at Decoder._decode (C:\Users\ironp\Project\discord-speech-recognition-cont\node_modules\discord.js\node_modules\prism-media\src\opus\Opus.js:64:25)
    at Decoder._transform (C:\Users\ironp\Project\discord-speech-recognition-cont\node_modules\discord.js\node_modules\prism-media\src\opus\Opus.js:204:22)
    at Decoder.Transform._read (internal/streams/transform.js:205:10)
    at Decoder.Transform._write (internal/streams/transform.js:193:12)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at Decoder.Writable.write (internal/streams/writable.js:303:10)
    at Readable.ondata (internal/streams/readable.js:719:22)
    at Readable.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
Emitted 'error' event on Decoder instance at:
    at Decoder.onerror (internal/streams/readable.js:760:14)
    at Decoder.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Rei-x commented 3 years ago

As far as I can see, I can't handle this error properly, because it occurs in event (and try catch doesn't work there). It's an issue with @discordjs/opus library - https://github.com/discordjs/opus/issues/49 If you find a solution, please create a pull request.

/edit Okay, nvm, maybe I have found a solution.

Rei-x commented 3 years ago

See #12 if it fixes your issue.