ohnoimdead

ohnoimdead

"key :decoder_start_token_id not found" trying to use Whisper with Bumblebee

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]
  )

Marked As Solved

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 : )

Also Liked

ohnoimdead

ohnoimdead

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"})

Where Next?

Popular in Questions Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New

We're in Beta

About us Mission Statement