AVSpeechSynthesizer not playing words objective - c ios 16

AVSpeechSynthesizer was not working. it was working perfect before.

below is my code objective - c.

-(void)playVoiceMemoforMessageEVO:(NSString*)msg {

[[AVAudioSession sharedInstance]
overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker
                  error:nil];

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
AVSpeechUtterance *speechutt = [AVSpeechUtterance speechUtteranceWithString:msg];
speechutt.volume=90.0f;
speechutt.rate=0.50f;
speechutt.pitchMultiplier=0.80f;
[speechutt setRate:0.3f];
speechutt.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-us"];
[synthesizer speakUtterance:speechutt];

} please help me to solve this issue.

Replies

Are you strongly retaining the synthesizer? You should be holding the synthesizer in a property at least until it finishes speaking the utterance.

Also there are some problems with AVSpeechSynthesizer which may or may not be related to your issue:

https://developer.apple.com/forums/thread/737685

https://developer.apple.com/forums/thread/730639