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

Is there a way to get timesliced data ? #6

Open
JoshuaeKaiser opened this issue Feb 21, 2021 · 1 comment
Open

Is there a way to get timesliced data ? #6

JoshuaeKaiser opened this issue Feb 21, 2021 · 1 comment

Comments

@JoshuaeKaiser
Copy link

Does the lib allow you to get the .wav or flac encoded data on an arbitrary timeslice ? Im looking to abstract the google speech to text service away from the client so the plan is to create the .wav or the flac on say 4 second intervals and pipe that to a server to proceed with the rest of the workflow. Couldnt see anything in the readme, any pointers would be greatly apreciated.

@russaa
Copy link
Contributor

russaa commented Feb 22, 2021

I guess you could implement something like this utilizing the block_size parameter (-> number of samples per block), see the libflac.js docs for initializing the encoder (or the block size setter)

the FLAC format specification eplains the meaning of block and block size in more detail

basically, you'd probably want to select a block size according to your sampling rate, so that your write-callback can collect encoded frames until your timeslice is met and then emit it
(but keep in mind the explanation of block size in the FLAC format description, i.e. it should not be too large or too small, e.g. I typically see 4096 for auto selected block size (for 44.1 kHz sampling rate))

(and note, that "normal" WAV usually requires a header for each chunk; there are variant formats for streaming e.g. audio/l16, but the receiving end/backend would need to be able to deal with that)

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