@min-pack/tfjs-node 2.17.1 → 3.8.1-patch.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/addon-node_modules/onnxruntime-node/bin/{napi-v3/linux/x64/libonnxruntime.so.1.14.0 → napi-v6/linux/arm64/libonnxruntime.so.1} +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1 +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node +0 -0
- package/index.d.ts +2 -0
- package/index.js +7102 -3371
- package/package.json +1 -10
- package/tfjs-types/backends/onnx.d.ts +37 -0
- package/tfjs-types/base/feature_extraction_utils.d.ts +41 -0
- package/tfjs-types/base/image_processors_utils.d.ts +332 -0
- package/tfjs-types/base/processing_utils.d.ts +89 -0
- package/tfjs-types/configs.d.ts +93 -0
- package/tfjs-types/env.d.ts +112 -0
- package/tfjs-types/generation/configuration_utils.d.ts +326 -0
- package/tfjs-types/generation/logits_process.d.ts +364 -0
- package/tfjs-types/generation/logits_sampler.d.ts +51 -0
- package/tfjs-types/generation/parameters.d.ts +47 -0
- package/tfjs-types/generation/stopping_criteria.d.ts +81 -0
- package/tfjs-types/generation/streamers.d.ts +88 -0
- package/tfjs-types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts +25 -0
- package/tfjs-types/models/auto/feature_extraction_auto.d.ts +5 -0
- package/tfjs-types/models/auto/image_processing_auto.d.ts +5 -0
- package/tfjs-types/models/auto/processing_auto.d.ts +39 -0
- package/tfjs-types/models/beit/image_processing_beit.d.ts +4 -0
- package/tfjs-types/models/bit/image_processing_bit.d.ts +4 -0
- package/tfjs-types/models/chinese_clip/image_processing_chinese_clip.d.ts +4 -0
- package/tfjs-types/models/clap/feature_extraction_clap.d.ts +57 -0
- package/tfjs-types/models/clip/image_processing_clip.d.ts +6 -0
- package/tfjs-types/models/convnext/image_processing_convnext.d.ts +12 -0
- package/tfjs-types/models/dac/feature_extraction_dac.d.ts +4 -0
- package/tfjs-types/models/deit/image_processing_deit.d.ts +6 -0
- package/tfjs-types/models/detr/image_processing_detr.d.ts +42 -0
- package/tfjs-types/models/dinov3_vit/image_processing_dinov3_vit.d.ts +4 -0
- package/tfjs-types/models/donut/image_processing_donut.d.ts +7 -0
- package/tfjs-types/models/dpt/image_processing_dpt.d.ts +6 -0
- package/tfjs-types/models/efficientnet/image_processing_efficientnet.d.ts +6 -0
- package/tfjs-types/models/encodec/feature_extraction_encodec.d.ts +13 -0
- package/tfjs-types/models/feature_extractors.d.ts +16 -0
- package/tfjs-types/models/florence2/processing_florence2.d.ts +39 -0
- package/tfjs-types/models/gemma3n/feature_extraction_gemma3n.d.ts +35 -0
- package/tfjs-types/models/gemma3n/processing_gemma3n.d.ts +31 -0
- package/tfjs-types/models/glpn/image_processing_glpn.d.ts +4 -0
- package/tfjs-types/models/grounding_dino/image_processing_grounding_dino.d.ts +20 -0
- package/tfjs-types/models/grounding_dino/processing_grounding_dino.d.ts +27 -0
- package/tfjs-types/models/idefics3/image_processing_idefics3.d.ts +40 -0
- package/tfjs-types/models/idefics3/processing_idefics3.d.ts +19 -0
- package/tfjs-types/models/image_processors.d.ts +44 -0
- package/tfjs-types/models/janus/image_processing_janus.d.ts +7 -0
- package/tfjs-types/models/janus/processing_janus.d.ts +77 -0
- package/tfjs-types/models/jina_clip/image_processing_jina_clip.d.ts +5 -0
- package/tfjs-types/models/jina_clip/processing_jina_clip.d.ts +9 -0
- package/tfjs-types/models/llava/processing_llava.d.ts +12 -0
- package/tfjs-types/models/llava_onevision/image_processing_llava_onevision.d.ts +4 -0
- package/tfjs-types/models/mask2former/image_processing_mask2former.d.ts +4 -0
- package/tfjs-types/models/maskformer/image_processing_maskformer.d.ts +22 -0
- package/tfjs-types/models/mgp_str/processing_mgp_str.d.ts +64 -0
- package/tfjs-types/models/mobilenet_v1/image_processing_mobilenet_v1.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v2/image_processing_mobilenet_v2.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v3/image_processing_mobilenet_v3.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v4/image_processing_mobilenet_v4.d.ts +6 -0
- package/tfjs-types/models/mobilevit/image_processing_mobilevit.d.ts +6 -0
- package/tfjs-types/models/moonshine/feature_extraction_moonshine.d.ts +13 -0
- package/tfjs-types/models/moonshine/processing_moonshine.d.ts +17 -0
- package/tfjs-types/models/nougat/image_processing_nougat.d.ts +4 -0
- package/tfjs-types/models/owlv2/image_processing_owlv2.d.ts +4 -0
- package/tfjs-types/models/owlvit/image_processing_owlvit.d.ts +10 -0
- package/tfjs-types/models/owlvit/processing_owlvit.d.ts +8 -0
- package/tfjs-types/models/paligemma/processing_paligemma.d.ts +12 -0
- package/tfjs-types/models/parakeet/feature_extraction_parakeet.d.ts +22 -0
- package/tfjs-types/models/phi3_v/image_processing_phi3_v.d.ts +17 -0
- package/tfjs-types/models/phi3_v/processing_phi3_v.d.ts +21 -0
- package/tfjs-types/models/pixtral/image_processing_pixtral.d.ts +4 -0
- package/tfjs-types/models/pixtral/processing_pixtral.d.ts +12 -0
- package/tfjs-types/models/processors.d.ts +25 -0
- package/tfjs-types/models/pvt/image_processing_pvt.d.ts +4 -0
- package/tfjs-types/models/pyannote/feature_extraction_pyannote.d.ts +31 -0
- package/tfjs-types/models/pyannote/processing_pyannote.d.ts +19 -0
- package/tfjs-types/models/qwen2_vl/image_processing_qwen2_vl.d.ts +11 -0
- package/tfjs-types/models/qwen2_vl/processing_qwen2_vl.d.ts +17 -0
- package/tfjs-types/models/rt_detr/image_processing_rt_detr.d.ts +8 -0
- package/tfjs-types/models/sam/image_processing_sam.d.ts +103 -0
- package/tfjs-types/models/sam/processing_sam.d.ts +9 -0
- package/tfjs-types/models/sam2/image_processing_sam2.d.ts +2 -0
- package/tfjs-types/models/sam2/processing_sam2.d.ts +6 -0
- package/tfjs-types/models/sam3/image_processing_sam3.d.ts +2 -0
- package/tfjs-types/models/sapiens/image_processing_sapiens.d.ts +10 -0
- package/tfjs-types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts +34 -0
- package/tfjs-types/models/segformer/image_processing_segformer.d.ts +10 -0
- package/tfjs-types/models/siglip/image_processing_siglip.d.ts +4 -0
- package/tfjs-types/models/smolvlm/image_processing_smolvlm.d.ts +2 -0
- package/tfjs-types/models/smolvlm/processing_smolvlm.d.ts +2 -0
- package/tfjs-types/models/snac/feature_extraction_snac.d.ts +4 -0
- package/tfjs-types/models/speecht5/feature_extraction_speecht5.d.ts +4 -0
- package/tfjs-types/models/speecht5/processing_speecht5.d.ts +14 -0
- package/tfjs-types/models/swin2sr/image_processing_swin2sr.d.ts +5 -0
- package/tfjs-types/models/ultravox/processing_ultravox.d.ts +16 -0
- package/tfjs-types/models/vit/image_processing_vit.d.ts +6 -0
- package/tfjs-types/models/vitmatte/image_processing_vitmatte.d.ts +12 -0
- package/tfjs-types/models/vitpose/image_processing_vitpose.d.ts +26 -0
- package/tfjs-types/models/voxtral/processing_voxtral.d.ts +16 -0
- package/tfjs-types/models/wav2vec2/feature_extraction_wav2vec2.d.ts +19 -0
- package/tfjs-types/models/wav2vec2/processing_wav2vec2.d.ts +14 -0
- package/tfjs-types/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.d.ts +14 -0
- package/tfjs-types/models/wespeaker/feature_extraction_wespeaker.d.ts +23 -0
- package/tfjs-types/models/whisper/common_whisper.d.ts +8 -0
- package/tfjs-types/models/whisper/feature_extraction_whisper.d.ts +23 -0
- package/tfjs-types/models/whisper/generation_whisper.d.ts +76 -0
- package/tfjs-types/models/whisper/processing_whisper.d.ts +17 -0
- package/tfjs-types/models/yolos/image_processing_yolos.d.ts +10 -0
- package/tfjs-types/models.d.ts +4396 -0
- package/tfjs-types/ops/registry.d.ts +13 -0
- package/tfjs-types/pipelines.d.ts +2433 -0
- package/tfjs-types/tokenizers.d.ts +1002 -0
- package/tfjs-types/transformers.d.ts +27 -0
- package/tfjs-types/utils/audio.d.ts +160 -0
- package/tfjs-types/utils/constants.d.ts +8 -0
- package/tfjs-types/utils/core.d.ts +231 -0
- package/tfjs-types/utils/data-structures.d.ts +294 -0
- package/tfjs-types/utils/devices.d.ts +18 -0
- package/tfjs-types/utils/dtypes.d.ts +20 -0
- package/tfjs-types/utils/generic.d.ts +11 -0
- package/tfjs-types/utils/hub.d.ts +175 -0
- package/tfjs-types/utils/image.d.ts +141 -0
- package/tfjs-types/utils/maths.d.ts +282 -0
- package/tfjs-types/utils/tensor.d.ts +490 -0
- package/tfjs-types/utils/video.d.ts +37 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/libonnxruntime.so.1.14.0 +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { env } from "./env.js";
|
|
2
|
+
export * from "./pipelines.js";
|
|
3
|
+
export * from "./models.js";
|
|
4
|
+
export * from "./tokenizers.js";
|
|
5
|
+
export * from "./configs.js";
|
|
6
|
+
export * from "./utils/audio.js";
|
|
7
|
+
export * from "./utils/image.js";
|
|
8
|
+
export * from "./utils/video.js";
|
|
9
|
+
export * from "./utils/tensor.js";
|
|
10
|
+
export * from "./utils/maths.js";
|
|
11
|
+
export * from "./models/feature_extractors.js";
|
|
12
|
+
export * from "./models/auto/feature_extraction_auto.js";
|
|
13
|
+
export * from "./models/image_processors.js";
|
|
14
|
+
export * from "./models/auto/image_processing_auto.js";
|
|
15
|
+
export * from "./models/processors.js";
|
|
16
|
+
export * from "./models/auto/processing_auto.js";
|
|
17
|
+
export * from "./generation/streamers.js";
|
|
18
|
+
export * from "./generation/stopping_criteria.js";
|
|
19
|
+
export * from "./generation/logits_process.js";
|
|
20
|
+
export { FeatureExtractor } from "./base/feature_extraction_utils.js";
|
|
21
|
+
export { ImageProcessor } from "./base/image_processors_utils.js";
|
|
22
|
+
export { Processor } from "./base/processing_utils.js";
|
|
23
|
+
export type PretrainedModelOptions = import("./utils/hub.js").PretrainedModelOptions;
|
|
24
|
+
export type PretrainedProcessorOptions = import("./base/processing_utils.js").PretrainedProcessorOptions;
|
|
25
|
+
export type DataType = import("./utils/dtypes.js").DataType;
|
|
26
|
+
export type DeviceType = import("./utils/devices.js").DeviceType;
|
|
27
|
+
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to read audio from a path/URL.
|
|
3
|
+
* @param {string|URL} url The path/URL to load the audio from.
|
|
4
|
+
* @param {number} sampling_rate The sampling rate to use when decoding the audio.
|
|
5
|
+
* @returns {Promise<Float32Array>} The decoded audio as a `Float32Array`.
|
|
6
|
+
*/
|
|
7
|
+
export function read_audio(url: string | URL, sampling_rate: number): Promise<Float32Array>;
|
|
8
|
+
/**
|
|
9
|
+
* Generates a Hanning window of length M.
|
|
10
|
+
* See https://numpy.org/doc/stable/reference/generated/numpy.hanning.html for more information.
|
|
11
|
+
*
|
|
12
|
+
* @param {number} M The length of the Hanning window to generate.
|
|
13
|
+
* @returns {Float64Array} The generated Hanning window.
|
|
14
|
+
*/
|
|
15
|
+
export function hanning(M: number): Float64Array;
|
|
16
|
+
/**
|
|
17
|
+
* Generates a Hamming window of length M.
|
|
18
|
+
* See https://numpy.org/doc/stable/reference/generated/numpy.hamming.html for more information.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} M The length of the Hamming window to generate.
|
|
21
|
+
* @returns {Float64Array} The generated Hamming window.
|
|
22
|
+
*/
|
|
23
|
+
export function hamming(M: number): Float64Array;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a frequency bin conversion matrix used to obtain a mel spectrogram. This is called a *mel filter bank*, and
|
|
26
|
+
* various implementation exist, which differ in the number of filters, the shape of the filters, the way the filters
|
|
27
|
+
* are spaced, the bandwidth of the filters, and the manner in which the spectrum is warped. The goal of these
|
|
28
|
+
* features is to approximate the non-linear human perception of the variation in pitch with respect to the frequency.
|
|
29
|
+
* @param {number} num_frequency_bins Number of frequency bins (should be the same as `n_fft // 2 + 1`
|
|
30
|
+
* where `n_fft` is the size of the Fourier Transform used to compute the spectrogram).
|
|
31
|
+
* @param {number} num_mel_filters Number of mel filters to generate.
|
|
32
|
+
* @param {number} min_frequency Lowest frequency of interest in Hz.
|
|
33
|
+
* @param {number} max_frequency Highest frequency of interest in Hz. This should not exceed `sampling_rate / 2`.
|
|
34
|
+
* @param {number} sampling_rate Sample rate of the audio waveform.
|
|
35
|
+
* @param {string} [norm] If `"slaney"`, divide the triangular mel weights by the width of the mel band (area normalization).
|
|
36
|
+
* @param {string} [mel_scale] The mel frequency scale to use, `"htk"` or `"slaney"`.
|
|
37
|
+
* @param {boolean} [triangularize_in_mel_space] If this option is enabled, the triangular filter is applied in mel space rather than frequency space.
|
|
38
|
+
* This should be set to `true` in order to get the same results as `torchaudio` when computing mel filters.
|
|
39
|
+
* @returns {number[][]} Triangular filter bank matrix, which is a 2D array of shape (`num_frequency_bins`, `num_mel_filters`).
|
|
40
|
+
* This is a projection matrix to go from a spectrogram to a mel spectrogram.
|
|
41
|
+
*/
|
|
42
|
+
export function mel_filter_bank(num_frequency_bins: number, num_mel_filters: number, min_frequency: number, max_frequency: number, sampling_rate: number, norm?: string, mel_scale?: string, triangularize_in_mel_space?: boolean): number[][];
|
|
43
|
+
/**
|
|
44
|
+
* Calculates a spectrogram over one waveform using the Short-Time Fourier Transform.
|
|
45
|
+
*
|
|
46
|
+
* This function can create the following kinds of spectrograms:
|
|
47
|
+
* - amplitude spectrogram (`power = 1.0`)
|
|
48
|
+
* - power spectrogram (`power = 2.0`)
|
|
49
|
+
* - complex-valued spectrogram (`power = None`)
|
|
50
|
+
* - log spectrogram (use `log_mel` argument)
|
|
51
|
+
* - mel spectrogram (provide `mel_filters`)
|
|
52
|
+
* - log-mel spectrogram (provide `mel_filters` and `log_mel`)
|
|
53
|
+
*
|
|
54
|
+
* In this implementation, the window is assumed to be zero-padded to have the same size as the analysis frame.
|
|
55
|
+
* A padded window can be obtained from `window_function()`. The FFT input buffer may be larger than the analysis frame,
|
|
56
|
+
* typically the next power of two.
|
|
57
|
+
*
|
|
58
|
+
* @param {Float32Array|Float64Array} waveform The input waveform of shape `(length,)`. This must be a single real-valued, mono waveform.
|
|
59
|
+
* @param {Float32Array|Float64Array} window The windowing function to apply of shape `(frame_length,)`, including zero-padding if necessary. The actual window length may be
|
|
60
|
+
* shorter than `frame_length`, but we're assuming the array has already been zero-padded.
|
|
61
|
+
* @param {number} frame_length The length of the analysis frames in samples (a.k.a., `fft_length`).
|
|
62
|
+
* @param {number} hop_length The stride between successive analysis frames in samples.
|
|
63
|
+
* @param {Object} options
|
|
64
|
+
* @param {number} [options.fft_length=null] The size of the FFT buffer in samples. This determines how many frequency bins the spectrogram will have.
|
|
65
|
+
* For optimal speed, this should be a power of two. If `null`, uses `frame_length`.
|
|
66
|
+
* @param {number} [options.power=1.0] If 1.0, returns the amplitude spectrogram. If 2.0, returns the power spectrogram. If `null`, returns complex numbers.
|
|
67
|
+
* @param {boolean} [options.center=true] Whether to pad the waveform so that frame `t` is centered around time `t * hop_length`. If `false`, frame
|
|
68
|
+
* `t` will start at time `t * hop_length`.
|
|
69
|
+
* @param {string} [options.pad_mode="reflect"] Padding mode used when `center` is `true`. Possible values are: `"constant"` (pad with zeros),
|
|
70
|
+
* `"edge"` (pad with edge values), `"reflect"` (pads with mirrored values).
|
|
71
|
+
* @param {boolean} [options.onesided=true] If `true`, only computes the positive frequencies and returns a spectrogram containing `fft_length // 2 + 1`
|
|
72
|
+
* frequency bins. If `false`, also computes the negative frequencies and returns `fft_length` frequency bins.
|
|
73
|
+
* @param {number} [options.preemphasis=null] Coefficient for a low-pass filter that applies pre-emphasis before the DFT.
|
|
74
|
+
* @param {boolean} [options.preemphasis_htk_flavor=true] Whether to apply the pre-emphasis filter in the HTK flavor.
|
|
75
|
+
* @param {number[][]} [options.mel_filters=null] The mel filter bank of shape `(num_freq_bins, num_mel_filters)`.
|
|
76
|
+
* If supplied, applies this filter bank to create a mel spectrogram.
|
|
77
|
+
* @param {number} [options.mel_floor=1e-10] Minimum value of mel frequency banks.
|
|
78
|
+
* @param {string} [options.log_mel=null] How to convert the spectrogram to log scale. Possible options are:
|
|
79
|
+
* `null` (don't convert), `"log"` (take the natural logarithm) `"log10"` (take the base-10 logarithm), `"dB"` (convert to decibels).
|
|
80
|
+
* Can only be used when `power` is not `null`.
|
|
81
|
+
* @param {number} [options.reference=1.0] Sets the input spectrogram value that corresponds to 0 dB. For example, use `max(spectrogram)[0]` to set
|
|
82
|
+
* the loudest part to 0 dB. Must be greater than zero.
|
|
83
|
+
* @param {number} [options.min_value=1e-10] The spectrogram will be clipped to this minimum value before conversion to decibels, to avoid taking `log(0)`.
|
|
84
|
+
* For a power spectrogram, the default of `1e-10` corresponds to a minimum of -100 dB. For an amplitude spectrogram, the value `1e-5` corresponds to -100 dB.
|
|
85
|
+
* Must be greater than zero.
|
|
86
|
+
* @param {number} [options.db_range=null] Sets the maximum dynamic range in decibels. For example, if `db_range = 80`, the difference between the
|
|
87
|
+
* peak value and the smallest value will never be more than 80 dB. Must be greater than zero.
|
|
88
|
+
* @param {boolean} [options.remove_dc_offset=null] Subtract mean from waveform on each frame, applied before pre-emphasis. This should be set to `true` in
|
|
89
|
+
* order to get the same results as `torchaudio.compliance.kaldi.fbank` when computing mel filters.
|
|
90
|
+
* @param {number} [options.max_num_frames=null] If provided, limits the number of frames to compute to this value.
|
|
91
|
+
* @param {number} [options.min_num_frames=null] If provided, ensures the number of frames to compute is at least this value.
|
|
92
|
+
* @param {boolean} [options.do_pad=true] If `true`, pads the output spectrogram to have `max_num_frames` frames.
|
|
93
|
+
* @param {boolean} [options.transpose=false] If `true`, the returned spectrogram will have shape `(num_frames, num_frequency_bins/num_mel_filters)`. If `false`, the returned spectrogram will have shape `(num_frequency_bins/num_mel_filters, num_frames)`.
|
|
94
|
+
* @param {number} [options.mel_offset=0] Offset to add to the mel spectrogram to avoid taking the log of zero.
|
|
95
|
+
* @returns {Promise<Tensor>} Spectrogram of shape `(num_frequency_bins, length)` (regular spectrogram) or shape `(num_mel_filters, length)` (mel spectrogram).
|
|
96
|
+
*/
|
|
97
|
+
export function spectrogram(waveform: Float32Array | Float64Array, window: Float32Array | Float64Array, frame_length: number, hop_length: number, { fft_length, power, center, pad_mode, onesided, preemphasis, preemphasis_htk_flavor, mel_filters, mel_floor, log_mel, reference, min_value, db_range, remove_dc_offset, min_num_frames, max_num_frames, do_pad, transpose, mel_offset, }?: {
|
|
98
|
+
fft_length?: number;
|
|
99
|
+
power?: number;
|
|
100
|
+
center?: boolean;
|
|
101
|
+
pad_mode?: string;
|
|
102
|
+
onesided?: boolean;
|
|
103
|
+
preemphasis?: number;
|
|
104
|
+
preemphasis_htk_flavor?: boolean;
|
|
105
|
+
mel_filters?: number[][];
|
|
106
|
+
mel_floor?: number;
|
|
107
|
+
log_mel?: string;
|
|
108
|
+
reference?: number;
|
|
109
|
+
min_value?: number;
|
|
110
|
+
db_range?: number;
|
|
111
|
+
remove_dc_offset?: boolean;
|
|
112
|
+
max_num_frames?: number;
|
|
113
|
+
min_num_frames?: number;
|
|
114
|
+
do_pad?: boolean;
|
|
115
|
+
transpose?: boolean;
|
|
116
|
+
mel_offset?: number;
|
|
117
|
+
}): Promise<Tensor>;
|
|
118
|
+
/**
|
|
119
|
+
* Returns an array containing the specified window.
|
|
120
|
+
* @param {number} window_length The length of the window in samples.
|
|
121
|
+
* @param {string} name The name of the window function.
|
|
122
|
+
* @param {Object} options Additional options.
|
|
123
|
+
* @param {boolean} [options.periodic=true] Whether the window is periodic or symmetric.
|
|
124
|
+
* @param {number} [options.frame_length=null] The length of the analysis frames in samples.
|
|
125
|
+
* Provide a value for `frame_length` if the window is smaller than the frame length, so that it will be zero-padded.
|
|
126
|
+
* @param {boolean} [options.center=true] Whether to center the window inside the FFT buffer. Only used when `frame_length` is provided.
|
|
127
|
+
* @returns {Float64Array} The window of shape `(window_length,)` or `(frame_length,)`.
|
|
128
|
+
*/
|
|
129
|
+
export function window_function(window_length: number, name: string, { periodic, frame_length, center, }?: {
|
|
130
|
+
periodic?: boolean;
|
|
131
|
+
frame_length?: number;
|
|
132
|
+
center?: boolean;
|
|
133
|
+
}): Float64Array;
|
|
134
|
+
export class RawAudio {
|
|
135
|
+
/**
|
|
136
|
+
* Create a new `RawAudio` object.
|
|
137
|
+
* @param {Float32Array} audio Audio data
|
|
138
|
+
* @param {number} sampling_rate Sampling rate of the audio data
|
|
139
|
+
*/
|
|
140
|
+
constructor(audio: Float32Array, sampling_rate: number);
|
|
141
|
+
audio: Float32Array<ArrayBufferLike>;
|
|
142
|
+
sampling_rate: number;
|
|
143
|
+
/**
|
|
144
|
+
* Convert the audio to a wav file buffer.
|
|
145
|
+
* @returns {ArrayBuffer} The WAV file.
|
|
146
|
+
*/
|
|
147
|
+
toWav(): ArrayBuffer;
|
|
148
|
+
/**
|
|
149
|
+
* Convert the audio to a blob.
|
|
150
|
+
* @returns {Blob}
|
|
151
|
+
*/
|
|
152
|
+
toBlob(): Blob;
|
|
153
|
+
/**
|
|
154
|
+
* Save the audio to a wav file.
|
|
155
|
+
* @param {string} path
|
|
156
|
+
*/
|
|
157
|
+
save(path: string): Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
import { Tensor } from './tensor.js';
|
|
160
|
+
//# sourceMappingURL=audio.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const GITHUB_ISSUE_URL: "https://github.com/huggingface/transformers.js/issues/new/choose";
|
|
2
|
+
export const CONFIG_NAME: "config.json";
|
|
3
|
+
export const FEATURE_EXTRACTOR_NAME: "preprocessor_config.json";
|
|
4
|
+
export const IMAGE_PROCESSOR_NAME: "preprocessor_config.json";
|
|
5
|
+
export const PROCESSOR_NAME: "processor_config.json";
|
|
6
|
+
export const CHAT_TEMPLATE_NAME: "chat_template.jinja";
|
|
7
|
+
export const GENERATION_CONFIG_NAME: "generation_config.json";
|
|
8
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Core utility functions/classes for Transformers.js.
|
|
3
|
+
*
|
|
4
|
+
* These are only used internally, meaning an end-user shouldn't
|
|
5
|
+
* need to access anything here.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/core
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} InitiateProgressInfo
|
|
11
|
+
* @property {'initiate'} status
|
|
12
|
+
* @property {string} name The model id or directory path.
|
|
13
|
+
* @property {string} file The name of the file.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} DownloadProgressInfo
|
|
17
|
+
* @property {'download'} status
|
|
18
|
+
* @property {string} name The model id or directory path.
|
|
19
|
+
* @property {string} file The name of the file.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Object} ProgressStatusInfo
|
|
23
|
+
* @property {'progress'} status
|
|
24
|
+
* @property {string} name The model id or directory path.
|
|
25
|
+
* @property {string} file The name of the file.
|
|
26
|
+
* @property {number} progress A number between 0 and 100.
|
|
27
|
+
* @property {number} loaded The number of bytes loaded.
|
|
28
|
+
* @property {number} total The total number of bytes to be loaded.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {Object} DoneProgressInfo
|
|
32
|
+
* @property {'done'} status
|
|
33
|
+
* @property {string} name The model id or directory path.
|
|
34
|
+
* @property {string} file The name of the file.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {Object} ReadyProgressInfo
|
|
38
|
+
* @property {'ready'} status
|
|
39
|
+
* @property {string} task The loaded task.
|
|
40
|
+
* @property {string} model The loaded model.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {InitiateProgressInfo | DownloadProgressInfo | ProgressStatusInfo | DoneProgressInfo | ReadyProgressInfo} ProgressInfo
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* A callback function that is called with progress information.
|
|
47
|
+
* @callback ProgressCallback
|
|
48
|
+
* @param {ProgressInfo} progressInfo
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to dispatch progress callbacks.
|
|
53
|
+
*
|
|
54
|
+
* @param {ProgressCallback | null | undefined} progress_callback The progress callback function to dispatch.
|
|
55
|
+
* @param {ProgressInfo} data The data to pass to the progress callback function.
|
|
56
|
+
* @returns {void}
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
export function dispatchCallback(progress_callback: ProgressCallback | null | undefined, data: ProgressInfo): void;
|
|
60
|
+
/**
|
|
61
|
+
* Reverses the keys and values of an object.
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} data The object to reverse.
|
|
64
|
+
* @returns {Object} The reversed object.
|
|
65
|
+
* @see https://ultimatecourses.com/blog/reverse-object-keys-and-values-in-javascript
|
|
66
|
+
*/
|
|
67
|
+
export function reverseDictionary(data: any): any;
|
|
68
|
+
/**
|
|
69
|
+
* Escapes regular expression special characters from a string by replacing them with their escaped counterparts.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} string The string to escape.
|
|
72
|
+
* @returns {string} The escaped string.
|
|
73
|
+
*/
|
|
74
|
+
export function escapeRegExp(string: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a value is a typed array.
|
|
77
|
+
* @param {*} val The value to check.
|
|
78
|
+
* @returns {boolean} True if the value is a `TypedArray`, false otherwise.
|
|
79
|
+
*
|
|
80
|
+
* Adapted from https://stackoverflow.com/a/71091338/13989043
|
|
81
|
+
*/
|
|
82
|
+
export function isTypedArray(val: any): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Check if a value is an integer.
|
|
85
|
+
* @param {*} x The value to check.
|
|
86
|
+
* @returns {boolean} True if the value is a string, false otherwise.
|
|
87
|
+
*/
|
|
88
|
+
export function isIntegralNumber(x: any): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Determine if a provided width or height is nullish.
|
|
91
|
+
* @param {*} x The value to check.
|
|
92
|
+
* @returns {boolean} True if the value is `null`, `undefined` or `-1`, false otherwise.
|
|
93
|
+
*/
|
|
94
|
+
export function isNullishDimension(x: any): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Calculates the dimensions of a nested array.
|
|
97
|
+
*
|
|
98
|
+
* @param {any[]} arr The nested array to calculate dimensions for.
|
|
99
|
+
* @returns {number[]} An array containing the dimensions of the input array.
|
|
100
|
+
*/
|
|
101
|
+
export function calculateDimensions(arr: any[]): number[];
|
|
102
|
+
/**
|
|
103
|
+
* Replicate python's .pop() method for objects.
|
|
104
|
+
* @param {Object} obj The object to pop from.
|
|
105
|
+
* @param {string} key The key to pop.
|
|
106
|
+
* @param {*} defaultValue The default value to return if the key does not exist.
|
|
107
|
+
* @returns {*} The value of the popped key.
|
|
108
|
+
* @throws {Error} If the key does not exist and no default value is provided.
|
|
109
|
+
*/
|
|
110
|
+
export function pop(obj: any, key: string, defaultValue?: any): any;
|
|
111
|
+
/**
|
|
112
|
+
* Efficiently merge arrays, creating a new copy.
|
|
113
|
+
* Adapted from https://stackoverflow.com/a/6768642/13989043
|
|
114
|
+
* @param {Array[]} arrs Arrays to merge.
|
|
115
|
+
* @returns {Array} The merged array.
|
|
116
|
+
*/
|
|
117
|
+
export function mergeArrays(...arrs: any[][]): any[];
|
|
118
|
+
/**
|
|
119
|
+
* Compute the Cartesian product of given arrays
|
|
120
|
+
* @param {...Array} a Arrays to compute the product
|
|
121
|
+
* @returns {Array} Returns the computed Cartesian product as an array
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
export function product(...a: any[][]): any[];
|
|
125
|
+
/**
|
|
126
|
+
* Calculates the index offset for a given index and window size.
|
|
127
|
+
* @param {number} i The index.
|
|
128
|
+
* @param {number} w The window size.
|
|
129
|
+
* @returns {number} The index offset.
|
|
130
|
+
*/
|
|
131
|
+
export function calculateReflectOffset(i: number, w: number): number;
|
|
132
|
+
/**
|
|
133
|
+
* Save blob file on the web.
|
|
134
|
+
* @param {string} path The path to save the blob to
|
|
135
|
+
* @param {Blob} blob The blob to save
|
|
136
|
+
*/
|
|
137
|
+
export function saveBlob(path: string, blob: Blob): void;
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @param {Object} o
|
|
141
|
+
* @param {string[]} props
|
|
142
|
+
* @returns {Object}
|
|
143
|
+
*/
|
|
144
|
+
export function pick(o: any, props: string[]): any;
|
|
145
|
+
/**
|
|
146
|
+
* Calculate the length of a string, taking multi-byte characters into account.
|
|
147
|
+
* This mimics the behavior of Python's `len` function.
|
|
148
|
+
* @param {string} s The string to calculate the length of.
|
|
149
|
+
* @returns {number} The length of the string.
|
|
150
|
+
*/
|
|
151
|
+
export function len(s: string): number;
|
|
152
|
+
/**
|
|
153
|
+
* Count the occurrences of a value in an array or string.
|
|
154
|
+
* This mimics the behavior of Python's `count` method.
|
|
155
|
+
* @param {any[]|string} arr The array or string to search.
|
|
156
|
+
* @param {any} value The value to count.
|
|
157
|
+
*/
|
|
158
|
+
export function count(arr: any[] | string, value: any): number;
|
|
159
|
+
export type InitiateProgressInfo = {
|
|
160
|
+
status: "initiate";
|
|
161
|
+
/**
|
|
162
|
+
* The model id or directory path.
|
|
163
|
+
*/
|
|
164
|
+
name: string;
|
|
165
|
+
/**
|
|
166
|
+
* The name of the file.
|
|
167
|
+
*/
|
|
168
|
+
file: string;
|
|
169
|
+
};
|
|
170
|
+
export type DownloadProgressInfo = {
|
|
171
|
+
status: "download";
|
|
172
|
+
/**
|
|
173
|
+
* The model id or directory path.
|
|
174
|
+
*/
|
|
175
|
+
name: string;
|
|
176
|
+
/**
|
|
177
|
+
* The name of the file.
|
|
178
|
+
*/
|
|
179
|
+
file: string;
|
|
180
|
+
};
|
|
181
|
+
export type ProgressStatusInfo = {
|
|
182
|
+
status: "progress";
|
|
183
|
+
/**
|
|
184
|
+
* The model id or directory path.
|
|
185
|
+
*/
|
|
186
|
+
name: string;
|
|
187
|
+
/**
|
|
188
|
+
* The name of the file.
|
|
189
|
+
*/
|
|
190
|
+
file: string;
|
|
191
|
+
/**
|
|
192
|
+
* A number between 0 and 100.
|
|
193
|
+
*/
|
|
194
|
+
progress: number;
|
|
195
|
+
/**
|
|
196
|
+
* The number of bytes loaded.
|
|
197
|
+
*/
|
|
198
|
+
loaded: number;
|
|
199
|
+
/**
|
|
200
|
+
* The total number of bytes to be loaded.
|
|
201
|
+
*/
|
|
202
|
+
total: number;
|
|
203
|
+
};
|
|
204
|
+
export type DoneProgressInfo = {
|
|
205
|
+
status: "done";
|
|
206
|
+
/**
|
|
207
|
+
* The model id or directory path.
|
|
208
|
+
*/
|
|
209
|
+
name: string;
|
|
210
|
+
/**
|
|
211
|
+
* The name of the file.
|
|
212
|
+
*/
|
|
213
|
+
file: string;
|
|
214
|
+
};
|
|
215
|
+
export type ReadyProgressInfo = {
|
|
216
|
+
status: "ready";
|
|
217
|
+
/**
|
|
218
|
+
* The loaded task.
|
|
219
|
+
*/
|
|
220
|
+
task: string;
|
|
221
|
+
/**
|
|
222
|
+
* The loaded model.
|
|
223
|
+
*/
|
|
224
|
+
model: string;
|
|
225
|
+
};
|
|
226
|
+
export type ProgressInfo = InitiateProgressInfo | DownloadProgressInfo | ProgressStatusInfo | DoneProgressInfo | ReadyProgressInfo;
|
|
227
|
+
/**
|
|
228
|
+
* A callback function that is called with progress information.
|
|
229
|
+
*/
|
|
230
|
+
export type ProgressCallback = (progressInfo: ProgressInfo) => void;
|
|
231
|
+
//# sourceMappingURL=core.d.ts.map
|