mirror of
https://github.com/ClaperCo/Claper.git
synced 2026-09-02 12:15:42 +02:00
# Conflicts: # lib/claper_web/live/admin_live/event_live.ex # lib/claper_web/live/event_live/manage.ex # lib/claper_web/live/event_live/manage.html.heex # lib/claper_web/live/event_live/manager_settings_component.ex # lib/claper_web/router.ex # priv/gettext/de/LC_MESSAGES/default.po # priv/gettext/default.pot # priv/gettext/en/LC_MESSAGES/default.po # priv/gettext/es/LC_MESSAGES/default.po # priv/gettext/fr/LC_MESSAGES/default.po # priv/gettext/hu/LC_MESSAGES/default.po # priv/gettext/it/LC_MESSAGES/default.po # priv/gettext/lv/LC_MESSAGES/default.po # priv/gettext/nl/LC_MESSAGES/default.po
36 lines
935 B
Elixir
36 lines
935 B
Elixir
defmodule ClaperWeb.AudioChannel do
|
|
use Phoenix.Channel, log_handle_in: false
|
|
|
|
require Logger
|
|
|
|
alias Claper.Transcriptions.TranscriptionWorker
|
|
|
|
@impl true
|
|
def join("audio:" <> event_uuid, _params, socket) do
|
|
if socket.assigns[:authorized_event_uuid] == event_uuid do
|
|
{:ok, assign(socket, :event_uuid, event_uuid)}
|
|
else
|
|
{:error, %{reason: "unauthorized"}}
|
|
end
|
|
end
|
|
|
|
@impl true
|
|
def handle_in("audio_chunk", %{"data" => base64_audio}, socket) do
|
|
case Base.decode64(base64_audio) do
|
|
{:ok, audio_data} ->
|
|
try do
|
|
TranscriptionWorker.push_audio(socket.assigns.event_uuid, audio_data)
|
|
catch
|
|
kind, reason ->
|
|
Logger.warning("Failed to push audio: #{inspect(kind)} #{inspect(reason)}")
|
|
end
|
|
|
|
{:noreply, socket}
|
|
|
|
:error ->
|
|
Logger.warning("Received invalid base64 audio data")
|
|
{:noreply, socket}
|
|
end
|
|
end
|
|
end
|