Add API to get version information (#2309)
This commit is contained in:
@@ -129,6 +129,7 @@ set(sources
|
||||
utils.cc
|
||||
vad-model-config.cc
|
||||
vad-model.cc
|
||||
version.cc
|
||||
voice-activity-detector.cc
|
||||
wave-reader.cc
|
||||
wave-writer.cc
|
||||
@@ -337,6 +338,7 @@ if(SHERPA_ONNX_ENABLE_BINARY)
|
||||
add_executable(sherpa-onnx-offline-punctuation sherpa-onnx-offline-punctuation.cc)
|
||||
add_executable(sherpa-onnx-offline-source-separation sherpa-onnx-offline-source-separation.cc)
|
||||
add_executable(sherpa-onnx-online-punctuation sherpa-onnx-online-punctuation.cc)
|
||||
add_executable(sherpa-onnx-version sherpa-onnx-version.cc version.cc)
|
||||
add_executable(sherpa-onnx-vad sherpa-onnx-vad.cc)
|
||||
|
||||
if(SHERPA_ONNX_ENABLE_TTS)
|
||||
@@ -396,6 +398,7 @@ if(SHERPA_ONNX_ENABLE_BINARY)
|
||||
install(
|
||||
TARGETS
|
||||
${main_exes}
|
||||
sherpa-onnx-version
|
||||
DESTINATION
|
||||
bin
|
||||
)
|
||||
|
||||
17
sherpa-onnx/csrc/sherpa-onnx-version.cc
Normal file
17
sherpa-onnx/csrc/sherpa-onnx-version.cc
Normal file
@@ -0,0 +1,17 @@
|
||||
// sherpa-onnx/csrc/sherpa-onnx-version.cc
|
||||
//
|
||||
// Copyright (c) 2025 Xiaomi Corporation
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "sherpa-onnx/csrc/version.h"
|
||||
|
||||
int32_t main() {
|
||||
printf("sherpa-onnx version : %s\n", sherpa_onnx::GetVersionStr());
|
||||
printf("sherpa-onnx Git SHA1: %s\n", sherpa_onnx::GetGitSha1());
|
||||
printf("sherpa-onnx Git date: %s\n", sherpa_onnx::GetGitDate());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -312,7 +312,8 @@ static std::vector<std::string> MergeCharactersIntoWords(
|
||||
while (i < n) {
|
||||
const auto &w = words[i];
|
||||
if (w.size() >= 3 || (w.size() == 2 && !IsSpecial(w)) ||
|
||||
(w.size() == 1 && (IsPunct(w[0]) || std::isspace(static_cast<uint8_t>(w[0]))))) {
|
||||
(w.size() == 1 &&
|
||||
(IsPunct(w[0]) || std::isspace(static_cast<uint8_t>(w[0]))))) {
|
||||
if (prev != -1) {
|
||||
std::string t;
|
||||
for (; prev < i; ++prev) {
|
||||
|
||||
24
sherpa-onnx/csrc/version.cc
Normal file
24
sherpa-onnx/csrc/version.cc
Normal file
@@ -0,0 +1,24 @@
|
||||
// sherpa-onnx/csrc/version.h
|
||||
//
|
||||
// Copyright 2025 Xiaomi Corporation
|
||||
|
||||
#include "sherpa-onnx/csrc/version.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
|
||||
const char *GetGitDate() {
|
||||
static const char *date = "Fri Jun 20 11:22:52 2025";
|
||||
return date;
|
||||
}
|
||||
|
||||
const char *GetGitSha1() {
|
||||
static const char *sha1 = "6982b86c";
|
||||
return sha1;
|
||||
}
|
||||
|
||||
const char *GetVersionStr() {
|
||||
static const char *version = "1.12.1";
|
||||
return version;
|
||||
}
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
29
sherpa-onnx/csrc/version.h
Normal file
29
sherpa-onnx/csrc/version.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// sherpa-onnx/csrc/version.h
|
||||
//
|
||||
// Copyright 2025 Xiaomi Corporation
|
||||
#ifndef SHERPA_ONNX_CSRC_VERSION_H_
|
||||
#define SHERPA_ONNX_CSRC_VERSION_H_
|
||||
|
||||
namespace sherpa_onnx {
|
||||
|
||||
// Please don't free the returned pointer.
|
||||
// Please don't modify the memory pointed by the returned pointer.
|
||||
//
|
||||
// The memory pointed by the returned pointer is statically allocated.
|
||||
const char *GetVersionStr();
|
||||
|
||||
// Please don't free the returned pointer.
|
||||
// Please don't modify the memory pointed by the returned pointer.
|
||||
//
|
||||
// The memory pointed by the returned pointer is statically allocated.
|
||||
const char *GetGitSha1();
|
||||
|
||||
// Please don't free the returned pointer.
|
||||
// Please don't modify the memory pointed by the returned pointer.
|
||||
//
|
||||
// The memory pointed by the returned pointer is statically allocated.
|
||||
const char *GetGitDate();
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
|
||||
#endif // SHERPA_ONNX_CSRC_VERSION_H_
|
||||
Reference in New Issue
Block a user