swift - Speech Synthesis on iOS weird errors on loading, and no concurrency -


i'm using speech synth in avfoundation, creating instance of voice this:

import avfoundation  class canspeak {      let voices = avspeechsynthesisvoice.speechvoices()     let voicesynth = avspeechsynthesizer()     var voicetouse: avspeechsynthesisvoice?      init(){         voice in voices {             if voice.name == "arthur"             {                 voicetouse = voice             }         }     }      func saythis(_ phrase: string){         let utterance = avspeechutterance(string: phrase)         utterance.voice = voicetouse         utterance.rate = 0.5         voicesynth.speak(utterance)     } } 

i have 2 problems.

  1. there's no concurrency. calling function multiple times results in queuing of strings speak. don't want that. if there's multiple calls function, close together, i'd voice begin speaking, if means speaking on itself. how make happen?

2 - odd errors don't understand on loading:

2016-11-18 03:03:07.103349 mysktest[687:87489] 0x17415ee50 copy matching assets reply: xpc_type_dictionary { count = 2, transaction: 0, voucher = 0x0, contents = "assets" => : { length = 3620 bytes, contents = 0x62706c6973743030d4000100020003000400050006012d01... } "result" => : 0 } 2016-11-18 03:03:07.109254 mysktest[687:87489] 0x17015e610 copy assets attributes reply: xpc_type_dictionary { count = 1, transaction: 0, voucher = 0x0, contents = "result" => : 1 } 2016-11-18 03:03:07.109547 mysktest[687:87489] [mobileasseterror:1] unable copy asset attributes 2016-11-18 03:03:07.110080 mysktest[687:87489] not attribute 'localurl': error domain=mobileasseterror code=1 "unable copy asset attributes" userinfo={nsdescription=unable copy asset attributes} 2016-11-18 03:03:07.112341 mysktest[687:87489] 0x17015e610 copy assets attributes reply: xpc_type_dictionary { count = 1, transaction: 0, voucher = 0x0, contents = "result" => : 1 } 2016-11-18 03:03:07.112416 mysktest[687:87489] [mobileasseterror:1] unable copy asset attributes 2016-11-18 03:03:07.112523 mysktest[687:87489] not attribute 'localurl': error domain=mobileasseterror code=1 "unable copy asset attributes" userinfo={nsdescription=unable copy asset attributes} 2016-11-18 03:03:07.145658 mysktest[687:87489] 0x174341c30 copy matching assets reply: xpc_type_dictionary { count = 2, transaction: 0, voucher = 0x0, contents = "assets" => : { length = 4198 bytes, contents = 0x62706c6973743030d4000100020003000400050006016f01... } "result" => : 0 } 2016-11-18 03:03:07.148403 mysktest[687:87489] 0x17015e610 copy assets attributes reply: xpc_type_dictionary { count = 3, transaction: 0, voucher = 0x0, contents = "attributes" => : { length = 526 bytes, contents = 0x62706c6973743030d4010203040506232458247665727369... } "result" => : 0 "sandboxextension" => { length = 269, contents = "b72954a376beb759be03a6411c3e2649f9845fd1;00000000;00000000;0000000000000015;com.apple.assets.read;00000001;01000003;00000000000ca4fc;/private/var/mobileasset/assets/com_apple_mobileasset_voiceservices_customvoice/54ffb86ce0ecd2c5bf871303b5690d327a571428.asset/assetdata" } } 2016-11-18 03:03:07.149858 mysktest[687:87489] 0x1743414a0 copy assets attributes reply: xpc_type_dictionary { count = 2, transaction: 0, voucher = 0x0, contents = "attributes" => : { length = 526 bytes, contents = 0x62706c6973743030d4010203040506232458247665727369... } "result" => : 0 }

as #1, it's not gonna happen. speech synthesizer system shared resource, how system handles scheduling multiple requests out of our control clients of api. (note if reuse same synthesizer, queues utterances, if create multiple synthesizers, fails speak utterances requested while synthesizer speaking.)

dunno #2, sorry. looks diagnostic text, not error. worth filing bug about, since don't want logging diagnostics when there's no actual problem.

bonus answer: can use functional programming make selection of voice bit shorter:

let voice = avspeechsynthesisvoice.speechvoices().first(where: { $0.name == "arthur" }) 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -