0

AVSpeechSynthesizer가 말하는 동안 내 앱에서보기를 표시하고 말하기를 중지하면보기를 사라지게하고 싶습니다.AVSpeechSynthesizer - AVSpeechSynthesizer가 말하기로 설정되어 있고 말하기가 중지 된 경우

-(void)speakText { 
    AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init]; 
    float speechSpeed = 0.12; 
    AVSpeechUtterance *synUtt = [[AVSpeechUtterance alloc] initWithString:textString]; 
    [synUtt setRate:speechSpeed]; 
    [synUtt setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:selectedVoice]]; 
    [synthesizer speakUtterance:synUtt]; 


//BELOW TO APPEAR AND AND DISAPPEAR 

     [UIButton beginAnimations:nil context:nil]; 
     [UIButton setAnimationDuration:0.5]; 
     [UIButton setAnimationDelay:0.0]; 
     [UIButton setAnimationCurve:UIViewAnimationCurveEaseOut]; 
     _speakingScrollView.frame = CGRectMake(236, 675, _speakingScrollView.frame.size.width, _speakingScrollView.frame.size.height); 
     [self.view bringSubviewToFront:_speakingScrollView]; 
     [UIView commitAnimations]; 

} 

나는이 문제를 어떻게 해결할 수없는 것일까 요? 내가 본 사과 문서는

@property(nonatomic, readonly, getter=isSpeaking) BOOL speaking 

을 제안하지만 내 응용 프로그램으로이를 구현하는 방법을하지 운동을 할 수 있습니다.

답변

1

AVSpeechSynthesizer에 대한 문서를 빠르게 보면 delegate 속성이 있음을 알 수 있습니다.

음성 합성기에 대한 이벤트를 알릴 수 있도록 delegate을 설정하고 AVSpeechSynthesizerDelegate 프로토콜을 구현해야합니다. 같은

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer 
didFinishSpeechUtterance:(AVSpeechUtterance *)utterance; 

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer 
    didStartSpeechUtterance:(AVSpeechUtterance *)utterance; 

이벤트는 시작하고 정지 할 때 당신이 알고 싶은 생각, 당신에게 가장 흥미로운 일이 될 것이다. 취소, 일시 중지 및 계속하기위한 이벤트도 있습니다.이 이벤트는 UI를 숨기거나 표시하기 위해 구현하기를 원할 것입니다.

+0

답장을 보내 주셔서 감사합니다. 현재 - (void) speakText를 사용하여 DidFinishSpeechUtterance를 어떻게 호출 할 수 있습니까? @interface ViewController : UIViewController { – Manesh

+0

델리게이트 패턴 작동 방식에 대해 약간의 정보가 필요 하듯이 들립니다. 델리게이트 객체를 설정하면 해당 객체가 프로토콜을 구현하는 경우 대리자 메소드에 대한 호출을 수신합니다. – Jasarien