Can't text-to-speech on the device

I can use AVSpeechSynthesizer API for text-to-speech on the simulator yet it's not working on the real devices producing log as below. Any advice?



2015-06-19 13:50:00.521 AAC[555:73408] |AXSpeechAssetDownloader|error| ASAssetQuery error fetching results (for com.apple.MobileAsset.MacinTalkVoiceAssets) Error Domain=ASError Code=21 "The operation couldn’t be completed. (ASError error 21 - Unable to copy asset information)" UserInfo=0x155d96d70 {NSDescription=Unable to copy asset information}

2015-06-19 13:50:00.522 AAC[555:73408] Building MacinTalk voice for asset: (null)

2015-06-19 13:50:00.538 AAC[555:73408] |AXSpeechAssetDownloader|error| ASAssetQuery error fetching results (for com.apple.MobileAsset.MacinTalkVoiceAssets) Error Domain=ASError Code=21 "The operation couldn’t be completed. (ASError error 21 - Unable to copy asset information)" UserInfo=0x155e96d40 {NSDescription=Unable to copy asset information}

Replies

Have the same problem on Xcode7b3 simulator/iOS9pb1 device. Only English voice (for english utterance ofc) works.

Here is basic example that works in Xcode 6 (pronouncing "Hello" in thai language):

NSString *thaiText = @"สวัสดี";
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:thaiText];
utterance.rate = AVSpeechUtteranceMinimumSpeechRate;
utterance.volume = 1;
AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"th-TH"];
utterance.voice = voice;
[synthesizer speakUtterance:utterance];

Running same code in Xcode 7b3 causes error:

AXAlternativeVoices was unable to retrieve custom voice assets. This could possibly be caused by someone requesting voices they are not entitled to. Error: Error Domain=ASError Code=21 "The operation couldn’t be completed. (ASError error 21 - Unable to copy asset information)"

There is API change (no docs yet) that i believe broke the speech synthesis:

The AV Foundation framework (

AVFoundation.framework
) adds new
AVSpeechSynthesisVoice
API that lets you specify a voice by identifier, instead of by language. You can also use the
name
and
quality
properties to get information about a voice.

- https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html

I still have the above error but atleast my TTS is working on my device. I had not enabled the AVAudioSession.


do{

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)

do{

try AVAudioSession.sharedInstance().setActive(true)

}catch{

}

}catch{

}