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.
Stops the client process. A proxy for GenServer.stop/3
.
Link to this section Functions
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
send_data(client, data)
View Source
send_data(GenServer.server(), iodata()) :: :ok
send_data(GenServer.server(), iodata()) :: :ok
Sends audio data over websocket
send_message(client, msg)
View Source
send_message(
GenServer.server(),
IBMSpeechToText.Message.Start.t() | IBMSpeechToText.Message.Stop.t()
) :: :ok
send_message( GenServer.server(), IBMSpeechToText.Message.Start.t() | IBMSpeechToText.Message.Stop.t() ) :: :ok
Sends a proper message over websocket to the API
start(api_region_or_url, api_key, opts \\ []) View Source
Starts a client process without links.
See start_link/3
for more info.
start_link(api_region_or_url, api_key, opts \\ []) View Source
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 ofstart_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"
)
stop(client, reason \\ :normal, timeout \\ :infinity)
View Source
stop(GenServer.server(), reason :: term(), GenServer.timeout()) :: :ok
stop(GenServer.server(), reason :: term(), GenServer.timeout()) :: :ok
Stops the client process. A proxy for GenServer.stop/3
.