---
title: "write(_:toBufferCallback:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avspeechsynthesizer/write(_:tobuffercallback:)"
---

# write(_:toBufferCallback:)

Generates speech for the utterance and invokes the callback with the audio buffer.

## Declaration

```swift
func write(_ utterance: AVSpeechUtterance, toBufferCallback bufferCallback: @escaping AVSpeechSynthesizer.BufferCallback)
```

## Parameters

- `utterance`: The utterance for synthesizing speech.
- `bufferCallback`: The system calls this closure with the generated audio buffer.

## Discussion

Discussion Call this method to receive audio buffers to store or further process synthesized speech.

## See Also

### Directing speech output

- [usesApplicationAudioSession](avfaudio/avspeechsynthesizer/usesapplicationaudiosession.md)
- [mixToTelephonyUplink](avfaudio/avspeechsynthesizer/mixtotelephonyuplink.md)
- [outputChannels](avfaudio/avspeechsynthesizer/outputchannels.md)
- [AVSpeechSynthesizer.BufferCallback](avfaudio/avspeechsynthesizer/buffercallback.md)
- [write(_:toBufferCallback:toMarkerCallback:)](avfaudio/avspeechsynthesizer/write(_:tobuffercallback:tomarkercallback:).md)
- [AVSpeechSynthesizer.MarkerCallback](avfaudio/avspeechsynthesizer/markercallback.md)
