Skip to content

Commit f861524

Browse files
committed
fix jpn ん && eng ' -
1 parent 2da8954 commit f861524

6 files changed

Lines changed: 251 additions & 56 deletions

File tree

‎plugins/G2P/multig2p/internal/V1/TaskImpl.cpp‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
#include <stdcorelib/str.h>
1010

11+
#include <synthrt/Core/Support/Logging.h>
1112
#include <synthrt/Core/Tensor/Tensor.h>
1213
#include <synthrt/G2P/Task/Task.h>
1314
#include <synthrt/G2P/Task/G2pTask.h>
1415

1516
namespace srt::g2p::plugins::Multig2p::Internal::V1 {
17+
static srt::LogCategory Log("Multig2p");
1618
namespace InferenceHelper {
1719
// ============== 预处理 ==============
1820

@@ -110,12 +112,12 @@ namespace srt::g2p::plugins::Multig2p::Internal::V1 {
110112

111113
// 构造 [B, maxLen] int64 张量(pad_idx 填充) + [B, maxLen] bool 张量
112114
std::vector<int64_t> srcData(B * maxLen, vocab.padIdx);
113-
std::vector<uint8_t> maskData(B * maxLen, 1); // true = pad
115+
srt::core::Tensor::Container maskData(B * maxLen, std::byte{1}); // true = pad
114116
for (size_t i = 0; i < B; ++i) {
115117
const auto &seq = sequences[i];
116118
for (size_t j = 0; j < seq.size(); ++j) {
117119
srcData[i * maxLen + j] = seq[j];
118-
maskData[i * maxLen + j] = 0; // false = 非pad
120+
maskData[i * maxLen + j] = std::byte{0}; // false = 非pad
119121
}
120122
}
121123

@@ -124,7 +126,8 @@ namespace srt::g2p::plugins::Multig2p::Internal::V1 {
124126
if (!srcExp) return srcExp.takeError();
125127

126128
const std::vector<int64_t> maskShape{static_cast<int64_t>(B), static_cast<int64_t>(maxLen)};
127-
auto maskExp = srt::core::Tensor::createFromView<uint8_t>(maskShape, stdc::array_view<uint8_t>{maskData});
129+
auto maskExp = srt::core::Tensor::createFromRawData(
130+
srt::core::ITensor::Bool, maskShape, std::move(maskData));
128131
if (!maskExp) return maskExp.takeError();
129132

130133
std::vector<int64_t> langIdsData(B);
@@ -853,6 +856,8 @@ namespace srt::g2p::plugins::Multig2p::Internal::V1 {
853856
}
854857
if (!decodeExp) {
855858
// 解码失败,按 fallback 处理(保留原 lyric)
859+
Log.srtWarning("Multig2p: decode failed for %1 word(s): %2",
860+
g2pInput->g2pInput.size(), decodeExp.error().message());
856861
auto g2pResult = srt::core::NO<srt::g2p::G2pResultV1>::create();
857862
g2pResult->g2pResult.reserve(g2pInput->g2pInput.size());
858863
for (const auto &lyric : g2pInput->g2pInput) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"$version": "1.0", "level": 1, "mode": "standard", "schema": {}, "configuration": {"steps": [{"step": "tagAndValidate", "params": {"tagger": [{"type": "regex", "value": ["([A-Z]+)"], "tag": "uppercase", "action": "copy"}, {"type": "regex", "value": ["(?i)([a-z]+)"], "tag": "mixed", "action": "convert"}]}}, {"step": "dict", "params": {"enabled": true, "file": "ds_cmudict-07b.txt"}}, {"step": "model", "params": {"enabled": true, "id": "g2p-multig2p-multi-official", "langRef": "eng/default", "batchSize": 20}}, {"step": "fallback", "params": {"useOriginal": true, "markFailed": true}}]}}
1+
{"$version": "1.0", "level": 1, "mode": "standard", "schema": {}, "configuration": {"steps": [{"step": "tagAndValidate", "params": {"tagger": [{"type": "regex", "value": ["([A-Z]+)"], "tag": "uppercase", "action": "copy"}, {"type": "regex", "value": ["(?i)([a-z'\\-]+)"], "tag": "mixed", "action": "convert"}]}}, {"step": "dict", "params": {"enabled": true, "file": "ds_cmudict-07b.txt"}}, {"step": "model", "params": {"enabled": true, "id": "g2p-multig2p-multi-official", "langRef": "eng/default", "batchSize": 20}}, {"step": "fallback", "params": {"useOriginal": true, "markFailed": true}}]}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"$version": "1.0", "level": 1, "mode": "standard", "schema": {}, "configuration": {"steps": [{"step": "tagAndValidate", "params": {"tagger": [{"type": "array", "value": ["SP", "AP", "EP"], "tag": "stopword", "action": "copy"}, {"type": "regex", "value": ["([\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}[ゃゅょぁぃぅぇぉャュョァィゥェォ]?)"], "tag": "kana", "action": "convert"}, {"type": "regex", "value": ["([A-Za-z]+)"], "tag": "latin", "action": "copy"}]}}, {"step": "dict", "params": {"enabled": true, "file": "kana2romaji.txt"}}, {"step": "fallback", "params": {"useOriginal": true, "markFailed": true}}]}}
1+
{"$version": "1.0", "level": 1, "mode": "standard", "schema": {}, "configuration": {"steps": [{"step": "tagAndValidate", "params": {"tagger": [{"type": "array", "value": ["SP", "AP", "EP"], "tag": "stopword", "action": "copy"}, {"type": "regex", "value": ["([\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}][ゃゅょぁぃぅぇぉャュョァィゥェォ]?)"], "tag": "kana", "action": "convert"}, {"type": "regex", "value": ["([A-Za-z]+)"], "tag": "latin", "action": "copy"}]}}, {"step": "dict", "params": {"enabled": true, "file": "kana2romaji.txt"}}, {"step": "fallback", "params": {"useOriginal": true, "markFailed": true}}]}}

‎resources/G2pPackages/Phonetic-Suite-Jpn/modules/ChainG2p-Jpn/kana2romaji.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
ろ ro
169169
わ wa
170170
を o
171-
ん N
171+
ん n
172172
ゔぁ va
173173
ゔぃ vi
174174
ゔ vu

‎tests/g2p/CMakeLists.txt‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,24 @@ target_include_directories(synthrt-test-g2p-langref PRIVATE
1616
${SYNTHRT_SOURCE_DIR}/include
1717
)
1818

19-
# L2 end-to-end test: Multig2p ONNX inference covering all 12 languages
20-
# supported by Phonetic-Suite-Multi. Gated behind SYNTHRT_ENABLE_L2_TESTS
21-
# (requires real ONNX Runtime + Multig2p plugin DLL + model files).
22-
if(SYNTHRT_ENABLE_L2_TESTS)
23-
synthrt_add_cross_test(synthrt-test-multig2p-languages tst_multig2p_languages.cpp)
24-
target_link_libraries(synthrt-test-multig2p-languages PRIVATE
25-
srt::g2p
26-
srt::core
27-
srt::driver
28-
)
29-
target_include_directories(synthrt-test-multig2p-languages PRIVATE
30-
${SYNTHRT_SOURCE_DIR}/include
31-
)
32-
target_compile_definitions(synthrt-test-multig2p-languages PRIVATE
33-
SYNTHRT_ENABLE_L2_TESTS
34-
SYNTHRT_TEST_SOURCE_DIR="${SYNTHRT_SOURCE_DIR}"
35-
SYNTHRT_TEST_BINARY_DIR="${CMAKE_BINARY_DIR}"
36-
)
37-
endif()
19+
# End-to-end test: Manager + plugin DLLs + real G2P packages (Multig2p ONNX
20+
# inference over all supported languages, plus the ChainG2p Eng/Jpn package
21+
# data regressions). Like every test in the tree it is unified under
22+
# SYNTHRT_BUILD_TESTS (see root CMakeLists note: no separate L2 level).
23+
# Requires real ONNX Runtime + plugin DLLs + package files at TEST time;
24+
# when they are missing the fixture reports setupError and all tests SKIP
25+
# gracefully instead of failing.
26+
synthrt_add_cross_test(synthrt-test-multig2p-languages tst_multig2p_languages.cpp)
27+
target_link_libraries(synthrt-test-multig2p-languages PRIVATE
28+
srt::g2p
29+
srt::core
30+
srt::driver
31+
srt::svs
32+
)
33+
target_include_directories(synthrt-test-multig2p-languages PRIVATE
34+
${SYNTHRT_SOURCE_DIR}/include
35+
)
36+
target_compile_definitions(synthrt-test-multig2p-languages PRIVATE
37+
SYNTHRT_TEST_SOURCE_DIR="${SYNTHRT_SOURCE_DIR}"
38+
SYNTHRT_TEST_BINARY_DIR="${CMAKE_BINARY_DIR}"
39+
)

0 commit comments

Comments
 (0)