0

I am using piece of code to speak my message with the help of AVSpeechSynthesizer. but i want same functionality to run on background mode. can we do it? Please tell me , how do i do it.

Thanks

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Driver Reached On Your Location"];
[utterance setRate:0.5f];
[synthesizer speakUtterance:utterance];
trungduc
  • 11,926
  • 4
  • 31
  • 55
manoj
  • 9
  • 5
  • 1
    Possible duplicate of [AVSpeechSynthesizer in background mode](https://stackoverflow.com/questions/19183591/avspeechsynthesizer-in-background-mode) – Sandeep Bhandari Jul 03 '18 at 07:09

1 Answers1

0

add this code in AppDelegate.m (didFinishLaunchingWithOptions)

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

please add App plays audio or streams audio/video using AirPlay under "Required background modes" property on your plist file

enter image description here

Jigar
  • 1,801
  • 1
  • 14
  • 29
  • Sorry i did not understand your answer, please be specific – manoj Jul 03 '18 at 07:20
  • i have done already but it is not working. i have found some text on log, please check [TTS] Error running custom voice query Error Domain=ASError Code=15 "Unable to copy asset information from https://mesu.apple.com/assets/ for asset type com.apple.MobileAsset.VoiceServices.GryphonVoice" UserInfo={NSDescription=Unable to copy asset information from https://mesu.apple.com/assets/ for asset type com.apple.MobileAsset.VoiceServices.GryphonVoice} – manoj Jul 03 '18 at 07:39
  • check this https://stackoverflow.com/questions/39868842/error-in-ios-10-unable-to-copy-asset-information-from-https-mesu-apple-com-a – Jigar Jul 03 '18 at 07:44