Skip to content

Commit fa9c13f

Browse files
[tfjs-data] Use '!IS_BROWSER' instead of 'IS_NODE' for detecting browser (#6240)
Make webcam and microphone iterators check the IS_BROWSER flag instead of the IS_NODE flag when checking environment compatability. This is more accurate because some browsers, like Electron, look like node but still have all the browser features required for webcams and microphones.
1 parent ab58c26 commit fa9c13f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tfjs-data/src/iterators/microphone_iterator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class MicrophoneIterator extends LazyIterator<TensorContainer> {
7777

7878
// Construct a MicrophoneIterator and start the audio stream.
7979
static async create(microphoneConfig: MicrophoneConfig = {}) {
80-
if (env().get('IS_NODE')) {
80+
if (!env().get('IS_BROWSER')) {
8181
throw new Error(
8282
'microphone API is only supported in browser environment.');
8383
}

tfjs-data/src/iterators/webcam_iterator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class WebcamIterator extends LazyIterator<Tensor3D> {
6767
// Construct a WebcamIterator and start it's video stream.
6868
static async create(
6969
webcamVideoElement?: HTMLVideoElement, webcamConfig: WebcamConfig = {}) {
70-
if (env().get('IS_NODE')) {
70+
if (!env().get('IS_BROWSER')) {
7171
throw new Error(
7272
'tf.data.webcam is only supported in browser environment.');
7373
}

0 commit comments

Comments
 (0)