microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
clipex

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

include/ortx_extractor.h

73lines · modecode

1// C ABI header file for the onnxruntime-extensions tokenization module
2
3#pragma once
4
5#include "ortx_utils.h"
6
7typedef OrtxObject OrtxFeatureExtractor;
8typedef OrtxObject OrtxRawAudios;
9typedef OrtxObject OrtxTensorResult;
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15/**
16 * @brief Creates a feature extractor object.
17 *
18 * This function creates a feature extractor object based on the provided feature definition.
19 *
20 * @param[out] extractor Pointer to a pointer to the created feature extractor object.
21 * @param[in] fe_def The feature definition used to create the feature extractor.
22 *
23 * @return An error code indicating the result of the operation.
24 */
25extError_t ORTX_API_CALL OrtxCreateSpeechFeatureExtractor(OrtxFeatureExtractor** extractor, const char* fe_def);
26
27/**
28 * Loads a collection of audio files into memory.
29 *
30 * This function loads a collection of audio files specified by the `audio_paths` array
31 * into memory and returns a pointer to the loaded audio data in the `audios` parameter.
32 *
33 * @param audios A pointer to a pointer that will be updated with the loaded audio data.
34 * The caller is responsible for freeing the memory allocated for the audio data.
35 * @param audio_paths An array of strings representing the paths to the audio files to be loaded.
36 * @param num_audios The number of audio files to be loaded.
37 *
38 * @return An `extError_t` value indicating the success or failure of the operation.
39 */
40extError_t ORTX_API_CALL OrtxLoadAudios(OrtxRawAudios** audios, const char* const* audio_paths, size_t num_audios);
41
42/**
43 * @brief Creates an array of raw audio objects, which refers to the audio data and sizes provided.
44 *
45 * This function creates an array of raw audio objects based on the provided data and sizes. The data will be stored in
46 * the `audios` parameter.
47 *
48 * @param audios Pointer to the variable that will hold the created raw audio objects.
49 * @param data Array of pointers to the audio data.
50 * @param sizes Array of pointers to the sizes of the audio data.
51 * @param num_audios Number of audio objects to create.
52 *
53 * @return extError_t Error code indicating the success or failure of the operation.
54 */
55extError_t ORTX_API_CALL OrtxCreateRawAudios(OrtxRawAudios** audios, const void* data[], const int64_t sizes[], size_t num_audios);
56
57/**
58 * @brief Calculates the log mel spectrogram for a given audio using the specified feature extractor.
59 *
60 * This function takes an instance of the OrtxFeatureExtractor struct, an instance of the OrtxRawAudios struct,
61 * and a pointer to an OrtxTensorResult pointer. It calculates the log mel spectrogram for the given audio using
62 * the specified feature extractor and stores the result in the provided log_mel pointer.
63 *
64 * @param extractor The feature extractor to use for calculating the log mel spectrogram.
65 * @param audio The raw audio data to process.
66 * @param log_mel A pointer to an OrtxTensorResult pointer where the result will be stored.
67 * @return An extError_t value indicating the success or failure of the operation.
68 */
69extError_t ORTX_API_CALL OrtxSpeechLogMel(OrtxFeatureExtractor* extractor, OrtxRawAudios* audio, OrtxTensorResult** log_mel);
70
71#ifdef __cplusplus
72}
73#endif
74