Skip to content

refactor and pybind of OnlineWebsocketServer #1943

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

manickavela29
Copy link
Contributor

@manickavela29 manickavela29 commented Feb 28, 2025

Hi @csukuangfj ,

I have refactored the previous implementation,
Below code base is functional tested and cleaned up

I think you can suggest more for naming for more clarity
or clean up.

overall summary,
-- refactoring online-websocket-server
-- pybind interface
-- signal termination, graceful shut down

Thanks

closed #1931

@manickavela29
Copy link
Contributor Author

Hi @csukuangfj,
could you approve for workflows, meanwhile you get time into review,
it will give me ample time to fix any failures

@csukuangfj
Copy link
Collaborator

Have you compiled and tested it locally?

Does it build successfully and also run successfully for you?

@manickavela29
Copy link
Contributor Author

yes, it is functional in my local testing with CUDA provider,

when I raised PR, observed that for some android build, it was failing with '#include "asio"',
so wanted to fix such issues meanwhile

@csukuangfj
Copy link
Collaborator

it was failing with '#include "asio"',

In that case, I suggest that you move the online-websocket-server.cc to sherpa-onnx/python/csrc.
It is better to not make sherpa-onnx-core contain websocket related stuff.

note that move there means you can change sherpa-onnx/python/csrc/CMakeLists.txt to include that .cc file.
You don't need to move that file physically to that folder.

@manickavela29
Copy link
Contributor Author

I have moved the WebSocket file to python/src object file and cleaned it, let me know if it is good enough

//
// Copyright (c) 2025 Uniphore (Author: Manickavela A)

#ifndef SHERPA_ONNX_PYTHON_CSRC_ONLINE_WEBSOCKET_SERVER_APP_H_
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the header guard to match the filename.

HINT: There is no app in the filename.


namespace sherpa_onnx {

void StartServerWrapper(py::list args) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that you refactor the OnlineWebSocketServer so that it can accept a pointer to an OnlineRecognizer in its constructor.

In this way, it can simplify how you construct an OnlineWebsocketServer.

You can reuse the methods form online_recognizer.py to construct an OnlineRecognizer and pass it to OnlineWebSocketServer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using OnlineRecognizer seems a little bit of a hassle as underlying OnlineWebsocketServer and Online
also has to be refactored and its seems like a bigger job

I would suggest OnlineWebsocketServer accepting OnlineRecognizerConfig in python/csrc/online-websocket-server-app.cc
I will take functions defined in online_recognizer.py and make them aligned for OnlineWebSocketServerConfig and feed it to pybind and c++, C++ functions will have a wrapper to accept this and start the server

let me know if its sounding good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe how much you need to refactor?

@manickavela29
Copy link
Contributor Author

Thanks for the suggestions, I will address them this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants