48 lines
1.3 KiB
Elixir
48 lines
1.3 KiB
Elixir
defmodule Whisper.SendToModel do
|
|
require Logger
|
|
|
|
def realtime(path) do
|
|
case Nx.Serving.batched_run(Whisper.RealtimeModel.Serving, {:file, path}) do
|
|
%{chunks: chunks} ->
|
|
chunks
|
|
|> Enum.map(& &1.text)
|
|
|> Enum.join(" ")
|
|
_ -> "Transcripción no disponible"
|
|
end
|
|
end
|
|
|
|
def transcribe_binary(audio_binary, serving) do
|
|
case Nx.Serving.batched_run(serving, {:binary, audio_binary}) do
|
|
%{chunks: chunks} ->
|
|
chunks
|
|
|> Enum.map(& &1.text)
|
|
|> Enum.join(" ")
|
|
_ ->
|
|
"Transcripción no disponible"
|
|
end
|
|
end
|
|
|
|
def large(path) do
|
|
case Nx.Serving.batched_run(Whisper.LargeModel.Serving, {:file, path}) do
|
|
%{chunks: chunks} ->
|
|
chunks
|
|
|> Enum.map(& &1.text)
|
|
|> Enum.join(" ")
|
|
_ -> "Transcripción no disponible"
|
|
end
|
|
end
|
|
# def realtime(path) do
|
|
# case Nx.Serving.batched_run(Whisper.RealtimeModel.Serving, {:file, path}) do
|
|
# %{chunks: chunks} -> chunks
|
|
# _ -> []
|
|
# end
|
|
# end
|
|
|
|
# def large(path) do
|
|
# case Nx.Serving.batched_run(Whisper.LargeModel.Serving, {:file, path}) do
|
|
# %{chunks: chunks} -> chunks
|
|
# _ -> []
|
|
# end
|
|
# end
|
|
|
|
end |