internal TextSearcherViewModel(ITextSearcher textSearcher) { mTextSearcher = textSearcher; mTextSearcherAsCaptionProvider = textSearcher as ICaptionProvider; mTextSearcherAsDescriptionProvider = textSearcher as IDescriptionProvider; mTextSearcherAsIconProvider = textSearcher as IIconProvider; }
public async void Start() { if (!string.IsNullOrEmpty(NotificationsJson)) { targets = NotificationTargetRequest.ParseJSON(NotificationsJson); } var notification = new Notification() { Level = Level.Info, Subject = "Session started", Message = string.Format("A new session with ID {0} was started on {1}", Id, DateTime.UtcNow) }; notification.TargetRequests.AddRange(targets); notification.Send(); systemLog.Debug($"{ LOG_PREFIX } Loading converter extension"); try { converter = Shared.Extensions.Instance.Converters .FirstOrDefault(t => t.Metadata.Name.Equals("CEA608") && t.Metadata.Version.Equals("1.0"))? .Value; } catch (Exception ex) { systemLog.Error($"{ LOG_PREFIX } Could not load converter extension; { ex.Message }"); systemLog.Debug(ex.StackTrace); } try { archive = Shared.Extensions.Instance.CaptionProviders .FirstOrDefault(t => t.Metadata.Name.Equals("Archive")) .Value; if (archive != null) { archive.SessionId = Id; archive.Init(); } } catch (Exception ex) { systemLog.Error(LOG_PREFIX + " Could not load archive extension", ex); } systemLog.Debug("Loading provider extension"); if (Encoder.EncoderType.Provider == null) { systemLog.Error(LOG_PREFIX + " Could not load provider extension"); return; } provider = Encoder.EncoderType.Provider.Value; if (provider == null) { systemLog.Error(LOG_PREFIX + " Could not load provider extension"); return; } switch (Encoder.EncoderType.Protocol) { case ProtocolType.Phone: provider.Endpoint = Encoder.PhoneNumber; break; case ProtocolType.Telnet: provider.Endpoint = Encoder.IpAddress + ":" + Encoder.Port; break; default: break; } provider.SessionId = Id; provider.Init(); systemLog.Debug(LOG_PREFIX + " Loading transcriber extensions"); try { //transcriber = Shared.Extensions.Instance.Transcribers // .FirstOrDefault(t => t.Metadata.Name.Equals("Microsoft Bing") && t.Metadata.Version.Equals("1.0"))? // .Value; transcriber = Shared.Extensions.Instance.Transcribers .FirstOrDefault(t => t.Metadata.Name.Equals("Watson") && t.Metadata.Version.Equals("2.0"))? .Value; //transcriber = Shared.Extensions.Instance.Transcribers // .FirstOrDefault(t => t.Metadata.Name.Equals("Google Cloud Speech") && t.Metadata.Version.Equals("1.0"))? // .Value; } catch (Exception ex) { systemLog.Error(LOG_PREFIX + " Could not load transcriber extension", ex); } if (transcriber != null) { systemLog.Debug(LOG_PREFIX + " Start transcribing"); transcriber.TextAvailable += HandleText; transcriber.Start(); State = SessionState.Active; StartTime = DateTime.UtcNow; sessionLog.Info($"{ LOG_PREFIX } Session { Id } started"); } if (Record) { StartRecording(); } if (Consumer != null) { Consumer.DataAvailable += HandleData; Consumer.Start(); } using (var entities = new Entities()) { entities.Entry(this).State = EntityState.Modified; await entities.SaveChangesAsync(); } }