2016-10-05 2 views
21

내 AVSpeechSynthesizer 코드가 장치 (iOS 10)에서 작동하지 않지만 iOS 9.x에서 작동하며 시뮬레이터에서 작동합니다.iOS10에서 AVSpeechSynthesizer가 작동하지 않습니다.

Unable to copy asset information from https://mesu.apple.com/assets/ for asset type 

사람이이 문제를 해결하는 방법을 알고 있나요 : 같은 오류 메시지가 있었다 그 전에

MobileAssetError:1] Unable to copy asset attributes 
Could not get attribute 'LocalURL': Error Domain=MobileAssetError Code=1 "Unable to copy asset attributes" 
UserInfo={NSDescription=Unable to copy asset attributes} 
0x1741495e0 Copy assets attributes reply: XPC_TYPE_DICTIONARY <dictionary: 0x1741495e0> { count = 1, transaction: 0, voucher = 0x0, contents = 
"Result" => <int64: 0x1744203a0>: 1} 

:

let str = self.audioOutput //just some string here, this string exists, and it's in english 
let synth = AVSpeechSynthesizer() 
let utterance = AVSpeechUtterance(string: str) 
    utterance.rate = AVSpeechUtteranceDefaultSpeechRate 
let lang = "en-US" 

utterance.voice = AVSpeechSynthesisVoice(language: lang) 
synth.speakUtterance(utterance) 

이 오류를 받고 있어요? 몇 가지 해결 방법이 있다는 것을 알고 있습니다 (예를 들어 사용자는 설정 -> 일반으로 이동하여 선택 선택으로 전환해야합니다). 그러나 실제 해결책이라고는 생각하지 않습니다.

업데이트 : 새 프로젝트 (XCode8/Swift3/다른 포드/프레임 워크 없음)를 만들었습니다. 그것은 시뮬레이터에서 작동하지만 내 장치에서 동일한 오류를 제공합니다.

업데이트 2 : 기기에서 작동합니다. 비슷한 오류 메시지가 있습니다 (자산 속성 등을 복사 할 수 없습니다). 그러나 지금은 작동합니다. 나는 그것이 무엇인지 모른다.

+0

이'AVSpeechSynthesisVoice (언어 : LANG) 있는지 확인하려고 :) ( 는 목소리 =의 AVSpeechSynthesisVoice.speechVoices하자 을'존재하지 않을 경우 ... 내가 그런 일을 시도 다른 언어 – TonyMkenu

+0

시도 목소리로 목소리로 { print ("\ (voice.언어) ") 인쇄 ("\ (voice.name) ") 인쇄 ("\ (voice.identifier) ​​") ​​ } 내가이? 충분히입니다"이 목록에 EN-US ". – lithium

+0

이 시도 : 다른 {반환}'대신'AVSpeechSynthesisVoice (언어 : LANG).' – TonyMkenu

답변

1

코드를 한 번 변경하고 작동 시키면됩니다. 시도 한번

synth.speak(utterance) 

내 전체 코드는 자동 모드 해제

**`import AVFoundation`** 


     let str = "once" //just some string here, this string exists, and it's in english 
     let synth = AVSpeechSynthesizer() 
     let utterance = AVSpeechUtterance(string: str) 
     utterance.rate = AVSpeechUtteranceDefaultSpeechRate 
     let lang = "en-US" 

     utterance.voice = AVSpeechSynthesisVoice(language: lang) 
     synth.speak(utterance) 
+0

그 변화는 Swift 3와 관련이 있습니다 (저자의 코드에서 Swift 2.3). 문제 해결 방법은 무엇입니까? –

+0

언어는 프레임 워크가 작동하는 방식을 변경하지 않습니다. Swift 2.3 또는 Swift 3.0을 사용하는 경우 둘 다 목표 C로 작성된 내부 프레임 워크를 호출합니다.이 문제는 사용 된 언어와 아무 관련이 없습니다. –

+0

당신은 말도 안되는 소리입니다. Xcode 8의 Swift 2.3에서 개발할 수 있으며 iOS 10에서 Xcode 7로 작성된 앱을 실행할 수 있습니다. –

10

를 켭니다 (물리적 스위치)와 같다. 제 경우에는 작동합니다.

+0

이것은 나에게도 도움이된다! 감사! – Karbaman

+0

당신은 나의 날을 구했습니다. –

3

내 프로젝트에서는 초기화 후 첫 번째 발화를 생성하는 데 문제가 있었지만 코드 재배치를 통해이를 해결할 수있었습니다. AVSpeechSynthesizer가 초기화 될 때와 첫 번째 발화가 생성 될 때 콘솔에는 여전히 수십 줄의 쓰레기가 배출됩니다. 여기에 약간의 샘플은 다음과 같습니다

2016-12-27 06:45:08.579510 SpeechBug1226[2155:859123] [MobileAssetError:1] Unable to copy asset attributes 
2016-12-27 06:45:08.580248 SpeechBug1226[2155:859123] Could not get attribute 'LocalURL': Error Domain=MobileAssetError Code=1 "Unable to copy asset attributes" UserInfo={NSDescription=Unable to copy asset attributes} 
2016-12-27 06:45:08.585959 SpeechBug1226[2155:859123] 0x174157fa0 Copy matching assets reply: XPC_TYPE_DICTIONARY <dictionary: 0x174157fa0> { count = 2, transaction: 0, voucher = 0x0, contents = 
"Assets" => <data: 0x17426c700>: { length = 1237 bytes, contents = 0x62706c6973743030d4010203040506636458247665727369... } 
"Result" => <int64: 0x174220180>: 0 

가 나는 small demo project이 재현 및 해결 방법을 찾을 수 없습니다. 슬프게도,이 질문에 대한 정답은 file a bug입니다. I just did :(

+0

감사합니다. 이것은 내가 미쳐 가지 않는다는 것을 증명한다. 이것에 관해서 아무것도 찾을 수 없었기 때문에 나는 그것이 내 코드라고 생각했다. 또한 그것을 재현하기위한 데모 프로젝트를 만들었 기 때문에 내 특정 장치 또는 무엇 때문인지 생각했습니다. 당신을 위해 초기화 할 때 잠시 멈 춥니 다 (메인 스레드 차단)? – Thermometer

+1

@Thermometer, 나는 그것을 알아 차리지 못했습니다. 물론, 단지 하나의 AVSpeechSynthesizer를 내 앱에서 만들고 다시 사용하기 때문입니다. 방금 측정 할 코드를 추가했는데'AVSpeechSynthesizer()'가 iPhone 5 시뮬레이터에서 1.2 초, 실제 iPad Mini에서 1.6 초 차단되었습니다. 실제로, 그것은 꽤 나쁘게 보인다. 그게 잠깐 * 당신이 의미하는 것입니까? –

+0

예. 당신이 그것을 측정 해 줘서 좋네요, 1.2 초는 제가 경험하고있는 얼어 붙은 것과 비슷합니다. 모달 viewcontroller를 열 때 ~ 1.5 초가 걸렸습니다. ViewDidLoad에서 AVSpeechSynthesizer를 초기화하는 것으로 나타났습니다. – Thermometer

5

iPad Mini 4에서이 동일한 문제가 발생했습니다.이 버전에는 물리적 스위치가 없습니다.하지만 열면 제어 센터 (스 와이프)하는 자동 버튼이 있습니다.이 해제하고 문제 수정 자체를 돌립니다.

내 시나리오에서

enter image description here

+1

문제가 스스로 해결되지 않습니다. – RegularExpression

1

, 나는 아이폰 인터넷 연결을 가능하게하여 해결할 수 있습니다.

A speech recognizer recognizes only one language. When you use the default initializer, you get a speech recognizer for the device's current locale, if a recognizer is supported for that locale. Note that a supported speech recognizer is not the same as an available speech recognizer; for example, the recognizers for some locales may require an Internet connection. You can use the supportedLocales() method to get a list of supported locales and the isAvailable property to find out if the recognizer for a specific locale is available.

코드에서

Source