Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Feb 13, 2025
1 parent 57b5ffa commit f3d0e38
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 30 deletions.
3 changes: 2 additions & 1 deletion sherpa-onnx/c-api/cxx-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ OfflineStream OfflineRecognizer::CreateStream() const {
return OfflineStream{s};
}

OfflineStream OfflineRecognizer::CreateStream(const std::string &hotwords) const {
OfflineStream OfflineRecognizer::CreateStream(
const std::string &hotwords) const {
auto s = SherpaOnnxCreateOfflineStreamWithHotwords(p_, hotwords.c_str());
return OfflineStream{s};
}
Expand Down
80 changes: 51 additions & 29 deletions sherpa-onnx/csrc/text-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -403,38 +403,60 @@ void ToLowerCase(std::string *in_out) {
std::wstring ToLowerCase(const std::wstring &s) {
std::wstring ans(s.size(), 0);
std::transform(s.begin(), s.end(), ans.begin(), [](wchar_t c) -> wchar_t {
switch(c) {
switch (c) {
// French
case L'À': return L'à';
case L'Â': return L'â';
case L'Æ': return L'æ';
case L'Ç': return L'ç';
case L'È': return L'è';
case L'É': return L'é';
case L'Ë': return L'ë';
case L'Î': return L'î';
case L'Ï': return L'ï';
case L'Ô': return L'ô';
case L'Ù': return L'ù';
case L'Û': return L'û';
case L'Ü': return L'ü';
case L'À':
return L'à';
case L'Â':
return L'â';
case L'Æ':
return L'æ';
case L'Ç':
return L'ç';
case L'È':
return L'è';
case L'É':
return L'é';
case L'Ë':
return L'ë';
case L'Î':
return L'î';
case L'Ï':
return L'ï';
case L'Ô':
return L'ô';
case L'Ù':
return L'ù';
case L'Û':
return L'û';
case L'Ü':
return L'ü';

// others
case L'Á': return L'á';
case L'Í': return L'í';
case L'Ó': return L'ó';
case L'Ú': return L'ú';
case L'Ñ': return L'ñ';
case L'Ì': return L'ì';
case L'Ò': return L'ò';
case L'Ä': return L'ä';
case L'Ö': return L'ö';
// TODO(fangjun): Add more

default: return std::towlower(c);
}
}
);
case L'Á':
return L'á';
case L'Í':
return L'í';
case L'Ó':
return L'ó';
case L'Ú':
return L'ú';
case L'Ñ':
return L'ñ';
case L'Ì':
return L'ì';
case L'Ò':
return L'ò';
case L'Ä':
return L'ä';
case L'Ö':
return L'ö';
// TODO(fangjun): Add more

default:
return std::towlower(c);
}
});
return ans;
}

Expand Down

0 comments on commit f3d0e38

Please sign in to comment.