elixir-nx / bumblebee

Pre-trained Neural Network models in Axon (+ 🤗 Models integration)
Apache License 2.0
1.27k stars 90 forks source link

running 'elixir speech_to_text.exs' UndefinedFunctionError #292

Closed bartonhammond closed 7 months ago

bartonhammond commented 7 months ago

macbook pro ventura 13.5

** (UndefinedFunctionError) function Bumblebee.Audio.speech_to_text_whisper/5 is undefined or private. Did you mean:

      * speech_to_text/4
      * speech_to_text/5

    (bumblebee 0.3.0) Bumblebee.Audio.speech_to_text_whisper(%{model: #Axon<
    inputs: %{"attention_head_mask" => {4, 6}, "cache" => nil, "cross_attention_head_mask" => {4, 6}, "decoder_attention_head_mask" => {4, 6}, "decoder_attention_mask" => {nil, nil}, "decoder_input_embeddings" => {nil, nil, 384}, "decoder_input_ids" => {nil, nil}, "encoder_hidden_state" => {nil, nil, 384}, "input_embeddings" => {nil, nil, 384}, "input_features" => {nil, 3000, 80}}
    outputs: "container_33"
    nodes: 841
josevalim commented 7 months ago

The whisper API was added in v0.4.0, so you have to update accordingly. :)

bartonhammond commented 7 months ago

I should have been more clear on how to repeat: I cloned the project and then ran the command following instructions in bumblebee/examples/phoenix/README.md. I don't understand what I'm supposed to update?
The speech_to_text.exs is self contained - I thought the purpose was to run from command line w/o any issues - it's an example.
I'll gladly update it and do a PR if I understood what to do.
I don't understand whisper API was added in v0.4.0 - added to what? I was able to run the other 2 examples w/o issues.

josevalim commented 7 months ago

I just pushed a commit that bumps bumblebee version. Please give it a try! I have a hunch that was not enough, we probably need to bump Nx and EXLA but it should point you in the right direction!

bartonhammond commented 7 months ago

Initial output from running

phoenix$ elixir speech_to_text.exs
Resolving Hex dependencies...
Resolution completed in 0.066s
Because bumblebee >= 0.3.1 depends on axon ~> 0.6.0 which depends on nx ~> 0.6.0, bumblebee >= 0.3.1 requires nx ~> 0.6.0.
And because your app depends on bumblebee ~> 0.4.0, nx ~> 0.6.0 is required.
So, because your app depends on nx ~> 0.5.1, version solving failed.
** (Mix.Error) Hex dependency resolution failed

So updated:

  {:nx, "~> 0.6.0"},
  {:exla, "~> 0.6.0"}

And it now compiles but with this:

Invalid call found at 5 locations:
  lib/phoenix_live_view/test/client_proxy.ex:1128: Phoenix.LiveViewTest.ClientProxy.form_defaults/3
  lib/phoenix_live_view/test/client_proxy.ex:1133: Phoenix.LiveViewTest.ClientProxy.form_defaults/3
  lib/phoenix_live_view/test/client_proxy.ex:1137: Phoenix.LiveViewTest.ClientProxy.form_defaults/3
  lib/phoenix_live_view/test/client_proxy.ex:1147: Phoenix.LiveViewTest.ClientProxy.form_defaults/3
  lib/phoenix_live_view/test/client_proxy.ex:1156: Phoenix.LiveViewTest.ClientProxy.form_defaults/3

Then testing the page w/ Microphone:


07:33:18.570 [info] JOINED lvu:1 in 584µs
  Parameters: %{"token" => "SFMyNTY.g2gDaAJhBXQAAAADZAADY2lkZAADbmlsZAADcGlkWGQADW5vbm9kZUBub2hvc3QAABTBAAAAAAAAAABkAANyZWZoAm0AAAAUcGh4LUY1bjFRT1BTVWFTUmljbmltAAAAATFuBgBnLzz3iwFiAAFRgA.Ya5t8vIClj9AMko59FQBuG_fTaarumeus3-3Xj5aNIw"}

07:33:21.453 [error] GenServer #PID<0.5313.0> terminating
** (FunctionClauseError) no function clause matching in PhoenixDemo.SampleLive.handle_info/2
    speech_to_text.exs:280: PhoenixDemo.SampleLive.handle_info({#Reference<0.1167719291.932511746.68009>, %{chunks: [%{end_timestamp_seconds: nil, start_timestamp_seconds: nil, text: " you"}]}}, #Phoenix.LiveView.Socket<id: "phx-F5n1QNawqFvLmMmi", endpoint: PhoenixDemo.Endpoint, view: PhoenixDemo.SampleLive, parent_pid: nil, root_pid: #PID<0.5313.0>, router: PhoenixDemo.Router, assigns: %{__changed__: %{}, flash: %{}, live_action: :index, task: %Task{mfa: {:erlang, :apply, 2}, owner: #PID<0.5313.0>, pid: #PID<0.5321.0>, ref: #Reference<0.1167719291.932511746.68140>}, transcription: nil, uploads: %{__phoenix_refs_to_names__: %{"phx-F5n1QOPSUaSRicni" => :audio}, audio: #Phoenix.LiveView.UploadConfig<name: :audio, max_entries: 1, max_file_size: 8000000, entries: [], accept: :any, ref: "phx-F5n1QOPSUaSRicni", errors: [], auto_upload?: true, progress_event: #Function<3.53987267/3 in PhoenixDemo.SampleLive.handle_progress>, ...>}}, transport_pid: #PID<0.5311.0>, ...>)
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/channel.ex:276: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 4.3) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.3) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {#Reference<0.1167719291.932511746.68009>, %{chunks: [%{end_timestamp_seconds: nil, start_timestamp_seconds: nil, text: " you"}]}}
State: %{components: {%{}, %{}, 1}, join_ref: "4", serializer: Phoenix.Socket.V2.JSONSerializer, socket: #Phoenix.LiveView.Socket<id: "phx-F5n1QNawqFvLmMmi", endpoint: PhoenixDemo.Endpoint, view: PhoenixDemo.SampleLive, parent_pid: nil, root_pid: #PID<0.5313.0>, router: PhoenixDemo.Router, assigns: %{__changed__: %{}, flash: %{}, live_action: :index, task: %Task{mfa: {:erlang, :apply, 2}, owner: #PID<0.5313.0>, pid: #PID<0.5321.0>, ref: #Reference<0.1167719291.932511746.68140>}, transcription: nil, uploads: %{__phoenix_refs_to_names__: %{"phx-F5n1QOPSUaSRicni" => :audio}, audio: #Phoenix.LiveView.UploadConfig<name: :audio, max_entries: 1, max_file_size: 8000000, entries: [], accept: :any, ref: "phx-F5n1QOPSUaSRicni", errors: [], auto_upload?: true, progress_event: #Function<3.53987267/3 in PhoenixDemo.SampleLive.handle_progress>, ...>}}, transport_pid: #PID<0.5311.0>, ...>, topic: "lv:phx-F5n1QNawqFvLmMmi", upload_names: %{}, upload_pids: %{}}

07:33:22.466 [debug] MOUNT PhoenixDemo.SampleLive
  Parameters: %{}
  Session: %{}

07:33:22.466 [debug] Replied in 241µs
bartonhammond commented 7 months ago

Thanks!