Posts

Post not yet marked as solved
1 Replies
164 Views
@interface MineViewController () @property (nonatomic, strong) AVSpeechSynthesizer *speechSynthesizer; @end @implementation MineViewController (void)speak { //version1 self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init]; self.speechSynthesizer.delegate = self; AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:@"12345678"]; AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"]; [utterance setVoice:voice]; //(worked speakUtterance successed) [self.speechSynthesizer speakUtterance:utterance]; //version2 AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc] init]; speechSynthesizer.delegate = self; AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:@"12345678"]; AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"]; [utterance setVoice:voice]; //(not worked speakUtterance no response) [speechSynthesizer speakUtterance:utterance]; } @end
Posted
by seppuu.
Last updated
.