Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "core/audio_utils"

Index

Variables

Const SAMPLE_RATE

SAMPLE_RATE: 16000 = 16000

Const WEBKIT_SAMPLE_RATE

WEBKIT_SAMPLE_RATE: 44100 = 44100

Const appeaseTsLintWindow

appeaseTsLintWindow: any = (window as any)

Const isSafari

isSafari: boolean = appeaseTsLintWindow.webkitOfflineAudioContext as boolean

Const offlineCtx

offlineCtx: any = isSafari ?new appeaseTsLintWindow.webkitOfflineAudioContext(1, WEBKIT_SAMPLE_RATE, WEBKIT_SAMPLE_RATE) :new appeaseTsLintWindow.OfflineAudioContext(1, SAMPLE_RATE, SAMPLE_RATE)

Functions

applyFilterbank

  • applyFilterbank(mags: Float32Array, filterbank: Float32Array[]): Float32Array

applyWholeFilterbank

  • applyWholeFilterbank(spec: Float32Array[], filterbank: Float32Array[]): Float32Array[]
  • Parameters

    • spec: Float32Array[]
    • filterbank: Float32Array[]

    Returns Float32Array[]

applyWindow

  • applyWindow(buffer: Float32Array, win: Float32Array): Float32Array

calculateFftFreqs

  • calculateFftFreqs(sampleRate: number, nFft: number): Float32Array

calculateMelFreqs

  • calculateMelFreqs(nMels: number, fMin: number, fMax: number): Float32Array

createMelFilterbank

  • createMelFilterbank(params: MelParams): Float32Array[]

fft

  • fft(y: Float32Array): any

frame

  • frame(data: Float32Array, frameLength: number, hopLength: number): Float32Array[]
  • Given a timeseries, returns an array of timeseries that are windowed according to the params specified.

    Parameters

    • data: Float32Array
    • frameLength: number
    • hopLength: number

    Returns Float32Array[]

getMonoAudio

  • getMonoAudio(audioBuffer: AudioBuffer): Float32Array

hannWindow

  • hannWindow(length: number): Float32Array

hzToMel

  • hzToMel(hz: number): number

internalDiff

  • internalDiff(arr: Float32Array): Float32Array

linearSpace

  • linearSpace(start: number, end: number, count: number): Float32Array

loadAudioFromFile

  • loadAudioFromFile(blob: Blob): Promise<AudioBuffer>
  • Loads audio into AudioBuffer from a Blob to transcribe.

    By default, audio is loaded at 16kHz monophonic for compatibility with model. In Safari, audio must be loaded at 44.1kHz instead.

    Parameters

    • blob: Blob

    Returns Promise<AudioBuffer>

    The loaded audio in an AudioBuffer.

loadAudioFromUrl

  • loadAudioFromUrl(url: string): Promise<AudioBuffer>
  • Loads audio into AudioBuffer from a URL to transcribe.

    By default, audio is loaded at 16kHz monophonic for compatibility with model. In Safari, audio must be loaded at 44.1kHz instead.

    Parameters

    • url: string

      A path to a audio file to load.

    Returns Promise<AudioBuffer>

    The loaded audio in an AudioBuffer.

mag

  • mag(y: Float32Array): Float32Array
  • Given an interlaced complex array (y_i is real, y_(i+1) is imaginary), calculates the energies. Output is half the size.

    Parameters

    • y: Float32Array

    Returns Float32Array

magSpectrogram

  • magSpectrogram(stft: Float32Array[], power: number): [Float32Array[], number]
  • Parameters

    • stft: Float32Array[]
    • power: number

    Returns [Float32Array[], number]

max

  • max(arr: Float32Array): number

melSpectrogram

  • melSpectrogram(y: Float32Array, params: SpecParams): Float32Array[]

melToHz

  • melToHz(mel: number): number

outerSubtract

  • outerSubtract(arr: Float32Array, arr2: Float32Array): Float32Array[]

padCenterToLength

  • padCenterToLength(data: Float32Array, length: number): Float32Array

padConstant

  • padConstant(data: Float32Array, padding: number | number[]): Float32Array

padReflect

  • padReflect(data: Float32Array, padding: number): Float32Array

pow

  • pow(arr: Float32Array, power: number): Float32Array

powerToDb

  • powerToDb(spec: Float32Array[], amin?: number, topDb?: number): Float32Array[]
  • Convert a power spectrogram (amplitude squared) to decibel (dB) units

    Intended to match librosa.core.power_to_db

    Parameters

    • spec: Float32Array[]

      Input power.

    • Default value amin: number = 1e-10

      Minimum threshold for abs(S).

    • Default value topDb: number = 80

      Threshold the output at topDb below the peak.

    Returns Float32Array[]

resampleAndMakeMono

  • resampleAndMakeMono(audioBuffer: AudioBuffer, targetSr?: number): Promise<any>
  • Parameters

    • audioBuffer: AudioBuffer
    • Default value targetSr: number = SAMPLE_RATE

    Returns Promise<any>

stft

  • stft(y: Float32Array, params: SpecParams): Float32Array[]

Generated using TypeDoc