[feature] Configurable padding length in online websocket server (#755)
Signed-off-by: manickavela29 <manickavela1998@gmail.com>
This commit is contained in:
@@ -19,12 +19,17 @@ void OnlineWebsocketDecoderConfig::Register(ParseOptions *po) {
|
||||
|
||||
po->Register("max-batch-size", &max_batch_size,
|
||||
"Max batch size for recognition.");
|
||||
|
||||
po->Register("end-tail-padding", &end_tail_padding,
|
||||
"It determines the length of tail_padding at the end of audio.");
|
||||
}
|
||||
|
||||
void OnlineWebsocketDecoderConfig::Validate() const {
|
||||
recognizer_config.Validate();
|
||||
SHERPA_ONNX_CHECK_GT(loop_interval_ms, 0);
|
||||
SHERPA_ONNX_CHECK_GT(max_batch_size, 0);
|
||||
SHERPA_ONNX_CHECK_GT(end_tail_padding, 0);
|
||||
|
||||
}
|
||||
|
||||
void OnlineWebsocketServerConfig::Register(sherpa_onnx::ParseOptions *po) {
|
||||
@@ -82,8 +87,7 @@ void OnlineWebsocketDecoder::InputFinished(std::shared_ptr<Connection> c) {
|
||||
c->samples.pop_front();
|
||||
}
|
||||
|
||||
// TODO(fangjun): Change the amount of paddings to be configurable
|
||||
std::vector<float> tail_padding(static_cast<int64_t>(0.8 * sample_rate));
|
||||
std::vector<float> tail_padding(static_cast<int64_t>(config_.end_tail_padding * sample_rate));
|
||||
|
||||
c->s->AcceptWaveform(sample_rate, tail_padding.data(), tail_padding.size());
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ struct OnlineWebsocketDecoderConfig {
|
||||
|
||||
int32_t max_batch_size = 5;
|
||||
|
||||
float end_tail_padding = 0.8;
|
||||
|
||||
void Register(ParseOptions *po);
|
||||
void Validate() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user