streaming python code sample ?

#5
by drzraf - opened

Dears,
It sounds like a very interesting and potent model for French.

But I wonder, aside from the sample cli and a fastrtc example on GitHub, do you happen to have a Python example of streaming usage?
Code-wide, this often differ a bit from regular file/known block size usage and would be very valuable addition !

drzraf changed discussion title from streaming python sample code to streaming python sample code?
drzraf changed discussion title from streaming python sample code? to streaming python code sample ?
Owner

Hello!

We are working hard on a new GitHub and Huggingface page with more examples (and more models). There will be a streaming python code example as well.
I Hope in a week we will be ready.

Banafo changed discussion status to closed

I explored https://github.com/kroko-ai/kroko-onnx but couldn't find an example.
Many examples aren't actually specific to Kroko ASR (I guess they may have been pulled from other repositories and it's creating a burden to extract the actually useful samples. python-api-examples comes from Xioami), and most of them a full regular file as input.

For simili-streaming, the audio is cut in small batches but there is no documentation that I could find about model training/batch sizing
This one for example: https://github.com/kroko-ai/kroko-onnx/blob/master/python-api-examples/streaming_server.py
set a wait time of 5ms and 3 batches (but I don't know how many samples contains a batch in this context) but I'm not sure these value are adequate for the Kroko models at all.

The documentation/example (regarding streaming) should really be adapted to this specific model in order to be useful.

A new commit has been pushed.

You can now use the following commands to run the streaming server with HTTP and CLI support:

cd kroko-onnx
pip install .
python3 python-api-examples/streaming_server.py --model MODEL.data

If you use Pro model, please provide the license key using the --key parameter too.

This starts the server with an HTTP interface and support for the CLI client. To test it, you can use the example client:

python3 python-api-examples/online-websocket-client-decode-file.py sample.wav

Notes:
The default parameters should work fine out of the box.
There is no enforced chunk size limit, but note:
There is no internal buffering in the python server example, so sending very large chunks(like 30sec duration) may cause memory issues.
The recommended chunk size is 800 samples per message for optimal performance.

Give it a try and let us know how it works for you.

Banafo changed discussion status to open

Sign up or log in to comment