Add C++ runtime and Python APIs for Moonshine models (#1473)
This commit is contained in:
34
sherpa-onnx/csrc/offline-moonshine-decoder.h
Normal file
34
sherpa-onnx/csrc/offline-moonshine-decoder.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// sherpa-onnx/csrc/offline-moonshine-decoder.h
|
||||
//
|
||||
// Copyright (c) 2023 Xiaomi Corporation
|
||||
|
||||
#ifndef SHERPA_ONNX_CSRC_OFFLINE_MOONSHINE_DECODER_H_
|
||||
#define SHERPA_ONNX_CSRC_OFFLINE_MOONSHINE_DECODER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "onnxruntime_cxx_api.h" // NOLINT
|
||||
|
||||
namespace sherpa_onnx {
|
||||
|
||||
struct OfflineMoonshineDecoderResult {
|
||||
/// The decoded token IDs
|
||||
std::vector<int32_t> tokens;
|
||||
};
|
||||
|
||||
class OfflineMoonshineDecoder {
|
||||
public:
|
||||
virtual ~OfflineMoonshineDecoder() = default;
|
||||
|
||||
/** Run beam search given the output from the moonshine encoder model.
|
||||
*
|
||||
* @param encoder_out A 3-D tensor of shape (batch_size, T, dim)
|
||||
* @return Return a vector of size `N` containing the decoded results.
|
||||
*/
|
||||
virtual std::vector<OfflineMoonshineDecoderResult> Decode(
|
||||
Ort::Value encoder_out) = 0;
|
||||
};
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
|
||||
#endif // SHERPA_ONNX_CSRC_OFFLINE_MOONSHINE_DECODER_H_
|
||||
Reference in New Issue
Block a user