ohnoimdead

ohnoimdead

Heya! Hope this is the right place for this question, if not I’m happy to move it.

I was trying to play around with speech-to-text using the OpenAI Whisper model in Livebook by kinda following along with Chris McCord’s YouTube video and this post from Dockyard: Audio Speech Recognition in Elixir with Whisper Bumblebee - DockYard. However, I’m getting the error:

** (KeyError) key :decoder_start_token_id not found in: [max_new_tokens: 100, defn_options: [compiler: EXLA]]. If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map
    (bumblebee 0.2.0) lib/bumblebee/text/generation.ex:135: Bumblebee.Text.Generation.build_generate/3
    (bumblebee 0.2.0) lib/bumblebee/audio/speech_to_text.ex:23: Bumblebee.Audio.SpeechToText.speech_to_text/5
    #cell:e4zqu3usyi6eu7maylexdftfnarnp432:6: (file)

Which, doing a little poking around, I think is related to specifying the language. I’ve got audio in en/US but not sure how to supply :decoder_start_token_id in this case (I’ve found some Python examples, but haven’t been able to get it to work in Elixir). I can’t find any examples of providing :decoder_start_token_id with Bumblebee.Audio.speech_to_text/4. Any help is greatly appreciated. For reference, here’s the .livebook source (in case I’m doing something stupid):


Mix.install([
  {:bumblebee, github: "elixir-nx/bumblebee"},
  {:exla, "~> 0.4"},
  {:nx, github: "elixir-nx/nx", sparse: "nx", override: true}
])

Section

Nx.default_backend(EXLA.Backend)

{:ok, whisper} = Bumblebee.load_model({:hf, "openai/whisper-tiny"})
{:ok, featurizer} = Bumblebee.load_featurizer({:hf, "openai/whisper-tiny"})
{:ok, tokenizer} = Bumblebee.load_tokenizer({:hf, "openai/whisper-tiny"})

serving =
  Bumblebee.Audio.speech_to_text(whisper, featurizer, tokenizer,
    max_new_tokens: 100,
    defn_options: [compiler: EXLA]
  )

Showing Posts 1 to 4

w0rd-driven

w0rd-driven

I believe you need exla 0.5+. I’m not at a place to see the Livebooks I’ve used but that all looks like a normal setup process. At some point you’ll also use bumblebee and nx versions because those declarations are both using the main branch on GitHub, which can be unstable at times.

I’d honestly copy the mix install parts according to this recent example: bumblebee/examples/phoenix/speech_to_text.exs at main · elixir-nx/bumblebee · GitHub

Bumblebee 0.2, exla 0.5.1+ and Nx 0.5.1+. All of these are moving quickly so I’ll be upgrading them very often for my experiments.

ohnoimdead

ohnoimdead OP

Hey, that got me a bit closer!

Now I’m seeing libc++abi: terminating with uncaught exception of type std::out_of_range: Span::at failed bounds check which I think is coming from exla and possibly related to I had Exla working at one point, but now it keeps crashing, and I can't figure out why - #13 by hbko

When I get a bit more time I’ll try recompiling exla with the instructions from that post and see if I can get it to work. I understand that all of this is moving quickly, I just thought it’d be fun to poke around. :smile:

Thanks!

EDIT: for reference, I’m on an M1 Max Pro. I just looked at the live_beats project to see if Chris McCord checked that stuff in (from https://www.youtube.com/watch?v=Yd220Te8cHc) but I don’t see any reference to bumblebee or nx in the mix.deps in trunk. It looks like he did that video from a Mac. :man_shrugging:

jonatanklosko

jonatanklosko

Creator of Livebook

Hey @ohnoimdead, you are installing Bumblebee directly form GitHub and we recently changed the API. The speech_to_text function accepts an additional argument, see this example. I will add a guard to make this transition less confusing : )

ohnoimdead

ohnoimdead OP

Awesome, thanks @jonatanklosko! For those playing along and trying to use latest Bumblebee in Livebook with the Whisper model, here’s what currently works for me:


Untitled notebook

Mix.install([
  {:bumblebee, github: "elixir-nx/bumblebee"},
  {:exla, "~> 0.4"},
  {:nx, github: "elixir-nx/nx", sparse: "nx", override: true}
])

Section

Nx.default_backend(EXLA.Backend)

{:ok, whisper} = Bumblebee.load_model({:hf, "openai/whisper-tiny"})
{:ok, featurizer} = Bumblebee.load_featurizer({:hf, "openai/whisper-tiny"})
{:ok, tokenizer} = Bumblebee.load_tokenizer({:hf, "openai/whisper-tiny"})
{:ok, generation_config} = Bumblebee.load_generation_config({:hf, "openai/whisper-tiny"})

serving =
  Bumblebee.Audio.speech_to_text(whisper, featurizer, tokenizer, generation_config,
    defn_options: [compiler: EXLA]
  )

Nx.Serving.run(serving, {:file, "/Users/tres/Desktop/foo.mp3"})
— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews