microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2d02a687beb1ba10319dc381b3907c91ab370995

Branches

Tags

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

Clone

HTTPS

Download ZIP

include/ortx_extractor.h

75lines · modecode

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