public async Task SpeechCommandDelegate() { if (_speechService.State.Equals(SpeechService.SpeechState.Stopped)) { await _speechService.Start(Message); } else { _speechService.Stop(); } }
public void SpeechStart(MeetingSettingModel setting) { speechService.Configruation((opt) => { opt.AppId = "5a31dec7"; opt.Rate = setting.Rate; opt.BitDepth = setting.BitDepth; opt.Channel = setting.Channel; opt.BufferMilliseconds = setting.BufferMilliseconds; opt.SentenceMilliseconds = setting.SentenceMilliseconds; opt.ByteLength = setting.ByteLength; opt.Speed = MeetingHelper.ConvertiFlySpeed(setting.Speed); opt.Language = MeetingHelper.GetiFlySpeechLang(setting.SourceLang); opt.Accent = MeetingHelper.ConvertiFlyAccent(setting.Accent);//"mandarin"; opt.OnResult = (key, result, complete) => { MeetingDataAdd(key, new MeetingSyncModel() { MeetingId = key, Content = result, SyncType = complete ? 0 : -1, }); var msg = $" Speech - OnResult : key[{key}] / result[{result}] / complete[{complete} / {DateTime.Now.ToString()} \n\r"; Console.WriteLine(msg); speechLog.Info(msg); }; opt.OnSentence = (key, sentence) => { speechLog.Info($" Speech - OnSentence : key[{key}] / sentence[{sentence}] / {DateTime.Now}"); }; opt.OnMessage = (key, msg) => { speechLog.Info($" Speech - OnMessage : key[{key}] / OnMessage[{msg}] / {DateTime.Now} \n\r"); }; opt.OnError = (key, error) => { //Trace.WriteLine //Console.WriteLine speechLog.Info($" Speech - OnError : key[{key}] / error[{error}] / {DateTime.Now}"); EngineHelper.LoggingError(error); speechService.Restart(); }; }); speechService.Start(); }