2017-07-03 67 views

回答

0

NSSpeechSynthesizer提供了一个接口的形式delegateINSSpeechSynthesizerDelegate)包含DidFinishSpeaking方法:

public partial class ViewController : NSViewController, INSSpeechSynthesizerDelegate 
{ 
    ~~~~~~ 

    public override void ViewDidLoad() 
    { 
     base.ViewDidLoad(); 

     var s = new NSSpeechSynthesizer(NSSpeechSynthesizer.DefaultVoice) 
     { 
      Delegate = this 
     }; 
     s.StartSpeakingString("StackOverflow"); 
    } 

    [Export("speechSynthesizer:didFinishSpeaking:")] 
    public void DidFinishSpeaking(NSSpeechSynthesizer sender, bool finishedSpeaking) 
    { 
     Console.WriteLine("Done speaking"); 
    } 

    ~~~~~~ 
} 
+0

非常感谢。有用 –

相关问题