Codex.Voice.Input (Codex SDK v0.7.2)

Copy Markdown View Source

Audio input types for voice pipelines.

This module provides two types of audio input:

  • AudioInput - A complete, static audio buffer
  • StreamedAudioInput - A streaming audio input that can be appended to

Both types support the standard PCM16 format at 24kHz, which is the default format for OpenAI's voice APIs.

Examples

# Static audio input
data = File.read!("recording.pcm")
input = AudioInput.new(data)
base64 = AudioInput.to_base64(input)

# Streaming audio input
input = StreamedAudioInput.new()
spawn(fn ->
  Enum.each(chunks, &StreamedAudioInput.add(input, &1))
  StreamedAudioInput.close(input)
end)
for chunk <- StreamedAudioInput.stream(input) do
  process(chunk)
end