Add API to get version information (#2309)

This commit is contained in:
Fangjun Kuang
2025-06-25 00:22:21 +08:00
committed by GitHub
parent 7f2145539d
commit bda427f4b2
169 changed files with 1480 additions and 12 deletions

View File

@@ -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
)

View 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;
}

View File

@@ -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) {

View 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

View 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_