defmodule WhisperWeb.VadLive do use WhisperWeb, :live_view alias Phoenix.PubSub def mount(_, _, socket) do PubSub.subscribe(Whisper.PubSub, "transcription") socket = socket |> assign(:transcription, "") |> assign(:started, false) {:ok, socket} end def handle_event("start_vad", _params, socket) do push_event(socket, "init-vad", %{}) {:noreply, assign(socket, started: true)} end def handle_info({:transcription, raw_json}, socket) do new_text = raw_json |> Jason.decode!() |> get_in(["chunks", Access.at(0), "text"]) {:noreply, update(socket, :transcription, &(&1 <> " " <> new_text))} end def render(assigns) do ~H"""
<%= if @transcription != "" do %>

✅ Transcripción

<%= @transcription %>

<% end %>
""" end end