From 67733a2a92f54d9777a0b18ac4f1488b3bc41efc Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 15 五月 2024 19:02:48 +0800
Subject: [PATCH] Merge branch 'dev_gzf_deepspeed' of github.com:alibaba-damo-academy/FunASR into dev_gzf_deepspeed merge
---
runtime/onnxruntime/src/phone-set.cpp | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/runtime/onnxruntime/src/phone-set.cpp b/runtime/onnxruntime/src/phone-set.cpp
index 167fa01..60eb101 100644
--- a/runtime/onnxruntime/src/phone-set.cpp
+++ b/runtime/onnxruntime/src/phone-set.cpp
@@ -13,7 +13,7 @@
namespace funasr {
PhoneSet::PhoneSet(const char *filename) {
ifstream in(filename);
- LoadPhoneSetFromYaml(filename);
+ LoadPhoneSetFromJson(filename);
}
PhoneSet::~PhoneSet()
{
@@ -35,6 +35,25 @@
}
}
+void PhoneSet::LoadPhoneSetFromJson(const char* filename) {
+ nlohmann::json json_array;
+ std::ifstream file(filename);
+ if (file.is_open()) {
+ file >> json_array;
+ file.close();
+ } else {
+ LOG(INFO) << "Error loading token file, token file error or not exist.";
+ exit(-1);
+ }
+
+ int id = 0;
+ for (const auto& element : json_array) {
+ phone_.push_back(element);
+ phn2Id_.emplace(element, id);
+ id++;
+ }
+}
+
int PhoneSet::Size() const {
return phone_.size();
}
--
Gitblit v1.9.1