-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ebranchformer #1951
Ebranchformer #1951
Conversation
- so ebranchformer feature extraction can be configured from Python - the GlobCmvn is not needed, at it is a module in the OnnxEncoder
81d6a00
to
41d378a
Compare
Thanks! Will review it today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Looks great to me. Left only some minor comments
sherpa-onnx/csrc/features.cc
Outdated
@@ -48,7 +48,9 @@ std::string FeatureExtractorConfig::ToString() const { | |||
os << "feature_dim=" << feature_dim << ", "; | |||
os << "low_freq=" << low_freq << ", "; | |||
os << "high_freq=" << high_freq << ", "; | |||
os << "dither=" << dither << ")"; | |||
os << "dither=" << dither << ", "; | |||
os << "normalize_samples=" << normalize_samples << ", "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os << "normalize_samples=" << normalize_samples << ", "; | |
os << "normalize_samples=" << (normalize_samples ? "True" : "False" )<< ", "; |
sherpa-onnx/csrc/features.cc
Outdated
os << "dither=" << dither << ")"; | ||
os << "dither=" << dither << ", "; | ||
os << "normalize_samples=" << normalize_samples << ", "; | ||
os << "snip_edges=" << snip_edges << ")"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os << "snip_edges=" << snip_edges << ")"; | |
os << "snip_edges=" << (snip_edges ? "True" : "False") << ")"; |
@@ -34,6 +51,9 @@ void PybindOnlineStream(py::module *m) { | |||
py::arg("sample_rate"), py::arg("waveform"), kAcceptWaveformUsage, | |||
py::call_guard<py::gil_scoped_release>()) | |||
.def("input_finished", &PyClass::InputFinished, | |||
py::call_guard<py::gil_scoped_release>()) | |||
.def("get_frames", &PyClass::GetFrames, | |||
py::arg("frame_index"), py::arg("n"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
py::arg("frame_index"), py::arg("n"), | |
py::arg("frame_index"), py::arg("n"), kGetFramesUsage |
so that if you use help(OnlineStream.get_frames)
, you can view the help info in python.
@@ -92,6 +96,8 @@ std::unique_ptr<OnlineTransducerModel> OnlineTransducerModel::Create( | |||
const auto &model_type = config.model_type; | |||
if (model_type == "conformer") { | |||
return std::make_unique<OnlineConformerTransducerModel>(config); | |||
} else if (model_type == "ebranchformer") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update
sherpa-onnx/sherpa-onnx/csrc/online-transducer-model.cc
Lines 180 to 181 in 41d378a
if (model_type == "conformer") { | |
return std::make_unique<OnlineConformerTransducerModel>(mgr, config); |
@@ -115,6 +121,8 @@ std::unique_ptr<OnlineTransducerModel> OnlineTransducerModel::Create( | |||
switch (model_type) { | |||
case ModelType::kConformer: | |||
return std::make_unique<OnlineConformerTransducerModel>(config); | |||
case ModelType::kEbranchformer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also update
sherpa-onnx/sherpa-onnx/csrc/online-transducer-model.cc
Lines 199 to 200 in 41d378a
case ModelType::kConformer: | |
return std::make_unique<OnlineConformerTransducerModel>(mgr, config); |
It is for Android and HarmonyOS.
(Please ignore the failed CI tests.) |
ok, good, thank you for the feedback, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
Hello Fangyun @csukuangfj ,
i did extend sherpa-onnx to support our EBranchformer encoder implementation
that we currently use widely at Brno University in Technology.
The EBranchformer code is based on Conformer
model
fromtransformers
, but the internals are different:https://github.com/BUTSpeechFIT/huggingface_asr/blob/streaming_karel/src/models/encoders/e_branchformer.py
This allows to pre-train the encoder with BestRQ alg. and then fine-tune with modified icefall.
We would like to deploy it as a production system for streaming ASR (it already works for me locally).
So for us it would be good to have the support directly inside sherpa-onnx,
so we can use the official sherpa-onnx builds.
On the other hand, it is a bit specific model, not yet widespread.
Would you agree on accepting this extension into the codebase ?
Or, should we rely on our cusom builds ?
The Encoder assumes little different preset of input features derived from
Speech2TextFeatureExtractor, hence newly surfacing the FBANK options:
normalize_samples
andsnip_edges
.Best regards,
Karel