View Source ExGoogleSTT.StreamingServer (Google Speech gRPC API v0.0.1)

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 t:Google.Cloud.Speech.V2.StreamingRecognizeRequest.t/0 struct created using Google.Cloud.Speech.V2.StreamingRecognizeRequest. 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 t:Google.Cloud.Speech.V2.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 Server
  2. Send a config request with Google.Cloud.Speech.V2.StreamingRecognitionConfig
  3. Send request(s) with Google.Cloud.Speech.V2.RecognitionAudio containing audio data
  4. (async) Receive messages conatining Google.Cloud.Speech.V2.StreamingRecognizeResponse
  5. Send final Google.Cloud.Speech.V2.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

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 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 linked client process.

Stops a client process.

Types

@type message() ::
  Google.Cloud.Speech.V2.StreamingRecognizeResponse.t()
  | {pid(), Google.Cloud.Speech.V2.StreamingRecognizeResponse.t()}

Format of messages sent by the client to the target

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec end_stream(client :: pid()) :: :ok

Closes a client-side gRPC stream.

Link to this function

send_config(pid, cfg_request, opts \\ [])

View Source
@spec send_config(
  client :: pid(),
  Google.Cloud.Speech.V2.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_request(pid, request, opts \\ [])

View Source
@spec send_request(
  client :: pid(),
  Google.Cloud.Speech.V2.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
@spec send_requests(
  client :: pid(),
  [Google.Cloud.Speech.V2.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_link(options \\ [])

View Source
@spec 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.
@spec stop(client :: pid()) :: :ok

Stops a client process.