Open cannoneyed opened 4 years ago
I would probably as a first step throw a clear error earlier in audio_utils. Something like "super sorry, this model does not work in node or a web worker because OfflineAudioContext"
The second step is kind of a pain, and like you said get a third party polyfill for OfflineAudioContext and do a similar dance like you did for fetch/performance.
@cannoneyed what's the status of this? You did a bit of work around it, is it ready to be closed?
When importing / using certain pieces of Magenta functionality in a web worker (namely anything that uses
audio_utils
, such as Transcription or GANSynth),OfflineAudioContext
doesn't exist and the browser-detecting code throws an errorhttps://github.com/magenta/magenta-js/blob/master/music/src/core/audio_utils.ts#L36-L39
Obviously, it doesn't make sense to use these models in a web worker without the AudioContext, but it is possible to import the audio_utils code through some other dependency trees (which I wasn't able to fully suss out)