Google Cloud Speech gRPC API v0.4.0 GCloud.SpeechAPI.Streaming.Client View Source

A client process for Streaming API.

Once a client is started, it establishes a connection to the Streaming API, gets ready to send requests to the API and forwards incoming responses to a set process.

Requests

The requests can be sent using send_request/3. Each request should be a Google.Cloud.Speech.V1.StreamingRecognizeRequest.t/0 struct created using Google.Cloud.Speech.V1.StreamingRecognizeRequest.new/1 accepting keyword with struct fields. This is an auto-generated module, so check out this notice and API reference

Responses

The client sends responses from API via messages to the target (by default it is the process that spawned client). Each message is a struct Google.Cloud.Speech.V1.StreamingRecognizeResponse.t/0 or a tuple with pid of sender and the same struct. Message format is controlled by include_sender option of a client.

Usage

  1. Start the client
  2. Send request with Google.Cloud.Speech.V1.StreamingRecognitionConfig
  3. Send request(s) with Google.Cloud.Speech.V1.RecognitionAudio containing audio data
  4. (async) Receive messages conatining Google.Cloud.Speech.V1.StreamingRecognizeResponse
  5. Send final Google.Cloud.Speech.V1.RecognitionAudio with option end_stream: true or call end_stream/1 after final audio chunk has been sent.
  6. Stop the client after receiving all results

See README for code example

Link to this section Summary

Types

Format of messages sent by the client to the target

Functions

Returns a specification to start this module under a supervisor.

Closes a client-side gRPC stream.

Sends a request to the API. If option end_stream: true is passed, closes a client-side gRPC stream.

Sends a list of requests to the API. If option end_stream: true is passed, closes a client-side gRPC stream.

Starts a client process without links.

Starts a linked client process.

Stops a client process.

Link to this section Types

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

end_stream(pid)

View Source
end_stream(client :: pid()) :: :ok

Closes a client-side gRPC stream.

Link to this function

send_request(pid, request, opts \\ [])

View Source
send_request(
  client :: pid(),
  Google.Cloud.Speech.V1.StreamingRecognizeRequest.t(),
  Keyword.t()
) :: :ok

Sends a request to the API. If option end_stream: true is passed, closes a client-side gRPC stream.

Link to this function

send_requests(pid, request, opts \\ [])

View Source
send_requests(
  client :: pid(),
  [Google.Cloud.Speech.V1.StreamingRecognizeRequest.t()],
  Keyword.t()
) :: :ok

Sends a list of requests to the API. If option end_stream: true is passed, closes a client-side gRPC stream.

Link to this function

start(options \\ [])

View Source
start(options :: Keyword.t()) :: {:ok, pid()} | {:error, any()}

Starts a client process without links.

See start_link/1 for more info

Link to this function

start_link(options \\ [])

View Source
start_link(options :: Keyword.t()) :: {:ok, pid()} | {:error, any()}

Starts a linked client process.

Possible options are:

  • target - A pid of a process that will receive recognition results. Defaults to self().
  • monitor_target - If set to true, a client will monitor the target and shutdown if the target is down
  • include_sender - If true, a client will include its pid in messages sent to the target.
  • start_time - Time by which response times will be shifted in nanoseconds. Defaults to 0 ns.
Link to this function

stop(pid)

View Source
stop(client :: pid()) :: :ok

Stops a client process.