Skip to content
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

How to stream pre-record audio file ? #10

Open
cevo2022 opened this issue Jul 22, 2022 · 2 comments
Open

How to stream pre-record audio file ? #10

cevo2022 opened this issue Jul 22, 2022 · 2 comments

Comments

@cevo2022
Copy link

Thank you for wonderful code. It work perfectly. However I curious on how to let this code broadcast pre-recorded audio file?

@aaknitt
Copy link
Owner

aaknitt commented Jul 23, 2022

Right now the source of the audio in the code is 60ms chunks of audio from the sound card here:

data = record(.06)

To send from a file, you'd probably want to instead use the Python wave module to read in the data from the file, and then iterate over it in 60 ms increments:

First call zello_ws = create_zello_connection() and start_stream(zello_ws), then iterate over the audiofile and in each iteration, encode the 60 ms chunk to opus format and then send it using zello_ws.send_binary. Then when done iterating over the file, call stop_stream and zello_ws.close().

For simplicity (least amount of code changes) you'd want the .wav file to be the same format and sampling rate as what the script is currently getting from the sound card - 16 bit mono at 16 kHz sampling rate.

@cevo2022
Copy link
Author

cevo2022 commented Jul 23, 2022 via email

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

No branches or pull requests

2 participants