# Service enfonica.voice.v1beta1.Streams

## Methods

| StreamCall :octicons-arrow-switch-24: |
| -- |
| <span class="e-code">rpc StreamCall(stream <span class="e-code">[StreamCallRequest](#streamcallrequest)</span>) returns (stream <span class="e-code">[StreamCallResponse](#streamcallresponse)</span>)</span><br/><br/>Operates a stream which can be bridged to by a call. This allows bi-directional audio to be passed. This method is only available via the gRPC API (not REST). If the stream is not connected to a call within 30 seconds of establishment, this method will fail. |

## StreamCallRequest

The top-level message sent by the client to the [StreamCall][enfonica.voice.v1beta1.Streams.StreamCall] method.

The first message must contain [setup][enfonica.voice.v1beta1.StreamCallRequest.setup] which sets the stream resource name and the audio configuration of the stream. The stream resource name should then be supplied to the VoiceML `<Stream>` action to connect a call to the stream.

Fields | &nbsp;
--|--
<span class="e-code">setup</span> | <span class="e-code">[StreamSetup](#streamsetup)</span><br/>The configuration of the stream. This must be specified in the first message in the request stream. It should not be specified in subsequent messages, however if it is, it will be ignored.
<span class="e-code">input_audio</span> | <span class="e-code">[InputAudio](#inputaudio)</span><br/>The input audio to play to the call. Input audio will be bufferred by the stream, unless [clear][enfonica.voice.v1beta1.InputAudio.clear] is true, in which case the buffer will be cleared and replaced with the specified audio. The size of the input buffer is limited to 1 minute. Audio specified beyond this limit will be truncated.
<span class="e-code">update_request_parameters</span> | <span class="e-code">[UpdateRequestParameters](#updaterequestparameters)</span><br/>Updates the request parameters of the subsequent VoiceML request once this stream has completed. This allows you to pass values to your VoiceML handler. Parameters specified in this message will be merged with any previous parameters that were specified.

## InputAudio

Represents audio content supplied by the API caller and played to the call.

Fields | &nbsp;
--|--
<span class="e-code">config</span> | <span class="e-code">[AudioConfig](#audioconfig)</span><br/>The configuration of the audio content. * If config is omitted, the audio configuration from the initial stream setup will be used. * If config is specified, it will be used, and if different to the audio configuration from the initial stream setup, the audio content will be transcoded.
<span class="e-code">audio</span> | <span class="e-code">bytes</span><br/>The audio content encoded as per the audio configuration. The maximum length of audio specified in one message is 960,000 bytes.
<span class="e-code">clear</span> | <span class="e-code">boolean</span><br/>If true, clears all previously bufferred audio.

## StreamSetup

Setup message to configure the stream.

Fields | &nbsp;
--|--
<span class="e-code">stream</span> | <span class="e-code">string</span><br/>The name of the stream. Format: `projects/<Project ID>/streams/<Stream ID>`. It's up to the API caller to choose an appropriate `Stream ID`. It must be unique and the length of `Stream ID` must not exceed 36 characters.
<span class="e-code">audio_config</span> | <span class="e-code">[AudioConfig](#audioconfig)</span><br/>The audio configuration of the stream. This will be used for both input and output audio.

## UpdateRequestParameters

Message to update the request parameters in the subsequent VoiceML request once the stream has completed.

Fields | &nbsp;
--|--
<span class="e-code">parameters</span> | <span class="e-code">map<<span class="e-code">string</span>, <span class="e-code">string</span>></span><br/>The request parameters to merge. The maximum aggregate size of all persisted keys and values is 50 KiB.

## AudioConfig

Description of the format of audio content.

Fields | &nbsp;
--|--
<span class="e-code">audio_encoding</span> | <span class="e-code">[AudioEncoding](#audioencoding)</span><br/>Required. Required. Audio encoding of the audio content.
<span class="e-code">sample_rate_hertz</span> | <span class="e-code">int32</span><br/>Sample rate (in Hertz) of the audio content.

## AudioEncoding

Audio encoding of audio content.

Enums | &nbsp;
--|--
<span class="e-code">AUDIO_ENCODING_UNSPECIFIED</span> | Not specified.
<span class="e-code">AUDIO_ENCODING_MULAW</span> | 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. Only supports 8000Hz sample rate.
<span class="e-code">AUDIO_ENCODING_ALAW</span> | 8-bit samples that compand 14-bit audio samples using G.711 PCMA/a-law. Only supports 8000Hz sample rate.

## StreamCallResponse

The top-level message returned from the [StreamCall][enfonica.voice.v1beta1.Streams.StreamCall] method.

Multiple response messages can be returned. The first response message will always have [call_connected][enfonica.voice.v1beta1.StreamCallResponse.call_connected] set, indicating that the stream has been connected to a call.

If the call is disconnected, the response stream will be closed.

Fields | &nbsp;
--|--
<span class="e-code">call_connected</span> | <span class="e-code">[CallConnectedEvent](#callconnectedevent)</span><br/>If set, the call has been connected to the stream. This will always be the first event in the response stream.
<span class="e-code">output_audio</span> | <span class="e-code">[OutputAudioEvent](#outputaudioevent)</span><br/>The audio received from the call. The stream will buffer the audio and send it in chunks. There is no specific size defined for each chunk, but it should be roughly in the range of 1000 to 2000 bytes.
<span class="e-code">input_audio_buffer_empty</span> | <span class="e-code">[InputAudioBufferEmptyEvent](#inputaudiobufferemptyevent)</span><br/>Indicates that the input audio specified to be played to the call has completed and the stream's buffer is empty.

## CallConnectedEvent

Event indicating a call has been connected to the stream.

Fields | &nbsp;
--|--
<span class="e-code">call</span> | <span class="e-code">string</span><br/>The resource name of the call that has been connected to the stream.

## InputAudioBufferEmptyEvent

Event indicating that the input audio has completed playing to the call.

This type has no fields.

## OutputAudioEvent

Event containing audio from the stream.

Fields | &nbsp;
--|--
<span class="e-code">audio</span> | <span class="e-code">bytes</span><br/>The audio content encoded as per the audio configuration requested during the initial stream setup.

