jonast
Resample 8000Hz s16le for use in Bumblebee whisper model (16000Hz 32f)
Hi folks, what’s the easiest way to use Membrane to resample from PCM single channel 8000Hz sample rate s16le to something I can use in the Whisper bumblebee model? (I believe 16000Hz 32f?)
For simplicity, let’s say I’d like to do this in a LiveBook and I’ve got a Binary of the raw 16bit audio frames loaded in memory
Most Liked
jerzywilczek
you should use our FFmpeg SWResample plugin. The docs contain an example of a thing similar to what you want to do, except for the fact that the input is a file instead of a in-memory binary. Let me know if you have any trouble!
jonast
Thanks so much both, that’s super useful. I can confirm that the resampled audio file plays as intended and the LiveBook no longer crashes
Will have a go at writing a BinarySrc plugin now
jerzywilczek
- Unfortunately we don’t have a plugin that allows a binary input or output, however it would be very simple to implement if you read the file plugin’s code, probably ~30-40 lines of code.
- The aborted state is a result of a crash of the pipeline. I don’t know why the error isn’t present in the cell output. There are two causes to the pipeline crashing. The first one is that as soon as you define a callback (such as
handle_element_end_of_stream) for one input case, the automatic implementation disappears, so when:file_srcreturns end of stream, membrane tries to callResampling.Pipeline.handle_element_end_of_stream(:file_src, _, _, _)and fails to find an implementation. The fix for this is simple: you need to define
The second problem is returning the... @impl true def handle_element_end_of_stream(:file_sink, _pad, _ctx_, _state) do {[playback: :stopped], nil} end @impl true def handle_element_end_of_stream(_child, _pad, _ctx, _state) do {[], nil} end ...playback: :stoppedaction, which doesn’t exist in membrane core v0.11. You should returnterminate: :normalinstead. - Functions that start a pipeline return
{:ok, supervisor_pid, pipeline_pid}in case of success, because the pipeline is always spawned under a dedicated supervisor. The supervisor never restarts the pipeline, but it makes sure that the pipeline and its children terminate properly. - The guide you’re referring to uses membrane core v0.7, and is unfortunately out of date : (. The
play()function was replaced with returning theplayback: :playingaction, which you did in yourhandle_init. I’m sorry the guides are outdated, we decided it would be better for now to focus on releasing core 1.0 and rewrite the old guides after that, since then the API will not change every couple months. - Try playing the files after resampling, since as I mentioned, they might be corrupted due to a bug we are currently having in out swresample plugin ;( We’re working on fixing it as soon as possible!
Hope this helps, let me know if you need anything else!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









