# `Codex.Voice.Input.AudioInput`
[🔗](https://github.com/nshkrdotcom/codex_sdk/blob/v0.18.1/lib/codex/voice/input.ex#L36)

A single, complete audio input buffer.

This struct holds static audio data along with its format parameters.
The default format is PCM16 at 24kHz mono, which is the standard format
for OpenAI's voice APIs.

# `t`

```elixir
@type t() :: %Codex.Voice.Input.AudioInput{
  channels: pos_integer(),
  data: binary(),
  frame_rate: pos_integer(),
  sample_width: pos_integer()
}
```

# `new`

```elixir
@spec new(
  binary(),
  keyword()
) :: t()
```

Create a new audio input from binary data.

## Options

- `:frame_rate` - Sample rate in Hz (default: 24000)
- `:sample_width` - Bytes per sample (default: 2)
- `:channels` - Number of audio channels (default: 1)

## Examples

    iex> data = <<0, 0, 255, 127>>
    iex> input = Codex.Voice.Input.AudioInput.new(data)
    iex> input.frame_rate
    24000

# `to_audio_file`

```elixir
@spec to_audio_file(t()) :: {String.t(), binary(), String.t()}
```

Convert audio to WAV file format.

Returns a tuple of `{filename, wav_data, mime_type}` suitable for
multipart uploads or file operations.

## Examples

    iex> data = <<0, 0, 255, 127>>
    iex> input = Codex.Voice.Input.AudioInput.new(data)
    iex> {filename, _wav_data, mime} = Codex.Voice.Input.AudioInput.to_audio_file(input)
    iex> {filename, mime}
    {"audio.wav", "audio/wav"}

# `to_base64`

```elixir
@spec to_base64(t()) :: String.t()
```

Encode audio data to base64.

This is useful when sending audio data to APIs that expect base64-encoded
audio.

## Examples

    iex> data = <<0, 0, 255, 127>>
    iex> input = Codex.Voice.Input.AudioInput.new(data)
    iex> Codex.Voice.Input.AudioInput.to_base64(input)
    "AAD/fw=="

---

*Consult [api-reference.md](api-reference.md) for complete listing*
