• Create an iterator that generates frequency-domain spectrogram Tensors from microphone audio stream with browser's native FFT. This API only works in browser environment when the device has microphone.

    Note: this code snippet only works when the device has a microphone. It will request permission to open the microphone when running.

    const mic = await tf.data.microphone({
    fftSize: 1024,
    columnTruncateLength: 232,
    numFramesPerSpectrogram: 43,
    sampleRateHz:44100,
    includeSpectrogram: true,
    includeWaveform: true
    });
    const audioData = await mic.capture();
    const spectrogramTensor = audioData.spectrogram;
    spectrogramTensor.print();
    const waveformTensor = audioData.waveform;
    waveformTensor.print();
    mic.stop();

    Parameters

    • Optional microphoneConfig: MicrophoneConfig

      A MicrophoneConfig object that contains configurations of reading audio data from microphone.

    Returns Promise<MicrophoneIterator>

    Doc

Generated using TypeDoc