###### tags: `Audio` `SwiftUI` `Siri`
# AVSpeechSynthesizer
:::danger
In iOS 17, AVSpeechSynthesizer cannot work properly. Check out the problem [here](https://developer.apple.com/forums/thread/737685)
:::
In <font color="red">`AVFoundation`</font>, there is a class named<font color="red">`AVSpeechSynthesizer`</font>. With <font color="red">`AVSpeechSynthesizer`</font> you can customize the texts that you want your app to speak.
### AVSpeechSynthesizer Declaration
```swift
class AVSpeechSynthesizer : NSObject
```
To configure the way your app speak, like voice, language, contents and so on, we use <font color="red">`AVSpeechUtterance`</font>.
### AVSpeechUtterance Declaration
```swift
class AVSpeechUtterance : NSObject
```
### Controlling Speech
```swift
func speak(_ utterance: AVSpeechUtterance)
func continueSpeaking() -> Bool
func pauseSpeaking(at boundary: AVSpeechBoundary) -> Bool
func stopSpeaking(at boundary: AVSpeechBoundary) -> Bool
```
You can notice that above the code we have a enum called <font color="red">`AVSpeechBoundary`</font>. <font color="red">`AVSpeechBoundary`</font> help us specifies when to pauce or stop speech. It contains two constants <font color="red">`immediate`</font> and <font color="red">`word`</font>
- immediate ⇒ Indicates to pause or stop speech immediately.
- word ⇒ Indicates to pause or stop speech after the synthesizer finishes speaking the current word.
### AVSpeechBoundary Declaration
```swift
enum AVSpeechBoundary : Int, @unchecked Sendable
```
# Reference
- [AVFoundation](https://developer.apple.com/documentation/avfoundation/)
- [AVSpeechSynthesizer](https://developer.apple.com/documentation/avfaudio/avspeechsynthesizer#declaration)
- [AVSpeechUtterance](https://developer.apple.com/documentation/avfaudio/avspeechutterance)