OmnivoiceEx.Server (omnivoice_ex v0.1.0)

Copy Markdown View Source

GenServer that manages a Python OmniVoice bridge via Erlang Port.

Protocol

Frame format: [4-byte BE total_length][msgpack-encoded payload]

Audio is WAV bytes inside msgpack — no base64.

Operations

  • init — Load model from HuggingFace
  • generate — TTS synthesis (synchronous, returns full audio)
  • ping — Health check

Summary

Functions

Waits for the model to finish loading.

Returns a specification to start this module under a supervisor.

Returns runtime model info: device, sample_rate, status.

Gracefully stops the GenServer and the Python bridge process.

Types

generate_opt()

@type generate_opt() ::
  {:ref_audio, String.t()}
  | {:ref_text, String.t()}
  | {:instruct, String.t()}
  | {:language, String.t()}
  | {:duration, float()}
  | {:speed, float()}
  | {:num_step, pos_integer()}
  | {:guidance_scale, float()}

model_option()

@type model_option() ::
  {:model, String.t()}
  | {:device, String.t()}
  | {:dtype, String.t()}
  | {:name, atom()}

start_opts()

@type start_opts() :: [model_option()]

Functions

await_ready(server, timeout \\ 120_000)

@spec await_ready(GenServer.server(), timeout()) :: :ok | {:error, term()}

Waits for the model to finish loading.

Returns :ok when ready, {:error, :loading} if still initializing, or {:error, reason} if initialization failed.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

generate(server, text, opts \\ [])

@spec generate(GenServer.server(), String.t(), [generate_opt()]) ::
  {:ok, binary()} | {:error, term()}

generate(server, text, opts, timeout)

@spec generate(GenServer.server(), String.t(), [generate_opt()], timeout()) ::
  {:ok, binary()} | {:error, term()}

info(server)

@spec info(GenServer.server()) :: map()

Returns runtime model info: device, sample_rate, status.

save(audio, path)

@spec save(binary(), Path.t()) :: :ok | {:error, term()}

start_link(opts \\ [])

@spec start_link(start_opts()) :: GenServer.on_start()

stop(server)

@spec stop(GenServer.server()) :: :ok

Gracefully stops the GenServer and the Python bridge process.