IBM Speech to Text v0.3.0 IBMSpeechToText.Client View Source

A client process responsible for communication with Speech to Text API

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Sends audio data over websocket

Sends a proper message over websocket to the API

Starts a client process without links.

Starts a client process responsible for communication with Speech to Text API linked to the current process.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

send_data(client, data) View Source
send_data(GenServer.server(), iodata()) :: :ok

Sends audio data over websocket

Sends a proper message over websocket to the API

Link to this function

start(api_region_or_url, api_key, opts \\ []) View Source
start(IBMSpeechToText.region() | charlist(), String.t(), Keyword.t()) ::
  :ignore | {:error, any()} | {:ok, pid()}

Starts a client process without links.

See start_link/3 for more info.

Link to this function

start_link(api_region_or_url, api_key, opts \\ []) View Source
start_link(IBMSpeechToText.region() | charlist(), String.t(), Keyword.t()) ::
  :ignore | {:error, any()} | {:ok, pid()}

Starts a client process responsible for communication with Speech to Text API linked to the current process.

Requires API url or region atom (See IBMSpeechToText.region/0) and an API key used to obtain IBMSpeechToText.Token (here you can learn how to get it)

Options

  • :stream_to - pid of the process that will receive recognition results, defaults to the caller of start_link/3
  • :keep_alive - if set to true, the client will automatically reconnect to the API after timeout (IBM API will close the connection after 30 seconds of silence or no data). False by default.
  • Recognition parameters (such as :model) described in IBM Cloud docs

Example

IBMSpeechToText.Client.start_link(
  :frankfurt,
  "ABCDEFGHIJKLMNO",
  model: "en-GB_BroadbandModel"
)
Link to this function

stop(client, reason \\ :normal, timeout \\ :infinity) View Source
stop(GenServer.server(), reason :: term(), GenServer.timeout()) :: :ok

Stops the client process. A proxy for GenServer.stop/3.