public Exercise(ILoggerService loggerService, ISpeechService speechService, string name, int setCount, int repetitionCount, IEnumerable<MatcherWithAction> matchersWithActions) { loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); name.AssertNotNull(nameof(name)); matchersWithActions.AssertNotNull(nameof(matchersWithActions)); if (setCount < 0) { throw new ArgumentException("setCount cannot be less than zero.", "setCount"); } if (repetitionCount < 0) { throw new ArgumentException("repetitionCount cannot be less than zero.", "repetitionCount"); } this.logger = loggerService.GetLogger(this.GetType()); this.speechService = speechService; this.name = name; this.setCount = setCount; this.repetitionCount = repetitionCount; this.matchersWithActions = matchersWithActions.ToImmutableList(); using (var dummyExecutionContext = new ExecutionContext()) { this.duration = this .GetEventsWithActions(dummyExecutionContext) .SelectMany(x => x.Actions) .Select(x => x.Duration) .DefaultIfEmpty() .Aggregate((running, next) => running + next); } }
public static Parser<IAction> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { if (indentLevel < 0) { throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel"); } audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); return BreakActionParser.GetParser(delayService, speechService) .Or<IAction>(MetronomeActionParser.GetParser(audioService, delayService, loggerService)) .Or<IAction>(PrepareActionParser.GetParser(delayService, speechService)) .Or<IAction>(SayActionParser.GetParser(speechService)) .Or<IAction>(WaitActionParser.GetParser(delayService)) .Or<IAction>(DoNotAwaitActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)) .Or<IAction>(ParallelActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)) .Or<IAction>(SequenceActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)); }
public static Parser<DoNotAwaitAction> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { if (indentLevel < 0) { throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel"); } audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); return from _ in Parse.IgnoreCase("don't") from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce() from ___ in Parse.IgnoreCase("wait:") from ____ in VerticalSeparationParser.Parser.AtLeastOnce() from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService) let child = new SequenceAction(actions) select new DoNotAwaitAction( loggerService, child); }
public SayAction(ISpeechService speechService, string speechText) { speechService.AssertNotNull(nameof(speechService)); speechText.AssertNotNull(nameof(speechText)); this.speechService = speechService; this.speechText = speechText; }
public SayAction(ISpeechService speechService, string speechText) { Ensure.ArgumentNotNull(speechService, nameof(speechService)); Ensure.ArgumentNotNull(speechText, nameof(speechText)); this.speechService = speechService; this.speechText = speechText; }
public RecipesRecipeDetail1ViewModel(INavigationService _NavigationService, ILiveTileService _LiveTileService, IDialogService _DialogService, IShareService _ShareService, ISpeechService _SpeechService) { this._NavigationService = _NavigationService; this._LiveTileService = _LiveTileService; this._DialogService = _DialogService; this._ShareService = _ShareService; this._SpeechService = _SpeechService; }
/// <summary> /// Initializes a new instance of the <see cref="VideoAlbum_DetailVideosViewModel" /> class. /// </summary> /// <param name="dialogService">The Dialog Service.</param> /// <param name="navigationService">The Navigation Service.</param> /// <param name="speechService">The Speech Service.</param> /// <param name="shareService">The Share Service.</param> /// <param name="liveTileService">The Live Tile Service.</param> public VideoAlbum_DetailVideosViewModel(IDialogService dialogService, INavigationService navigationService, ISpeechService speechService, IShareService shareService, ILiveTileService liveTileService) { _dialogService = dialogService; _navigationService = navigationService; _speechService = speechService; _shareService = shareService; _liveTileService = liveTileService; }
/// <summary> /// Initializes a new instance of the <see cref="AboutUsViewModel" /> class. /// </summary> /// <param name="dialogService">The Dialog Service.</param> /// <param name="navigationService">The Navigation Service.</param> /// <param name="speechService">The Speech Service.</param> /// <param name="shareService">The Share Service.</param> /// <param name="liveTileService">The Live Tile Service.</param> public AboutUsViewModel(IDialogService dialogService, INavigationService navigationService, ISpeechService speechService, IShareService shareService, ILiveTileService liveTileService) { _dialogService = dialogService; _navigationService = navigationService; _speechService = speechService; _shareService = shareService; _liveTileService = liveTileService; }
public RecipesRecipesListViewModel(INavigationService _NavigationService, IRecipeDataSource _RecipeDataSource, ILiveTileService _LiveTileService, IDialogService _DialogService, IShareService _ShareService, ISpeechService _SpeechService) { this._NavigationService = _NavigationService; this._RecipeDataSource = _RecipeDataSource; this._LiveTileService = _LiveTileService; this._DialogService = _DialogService; this._ShareService = _ShareService; this._SpeechService = _SpeechService; }
public ExerciseBuilder() { this.matchersWithActions = new List<MatcherWithAction>(); this.loggerService = new LoggerServiceMock(MockBehavior.Loose); this.speechService = new SpeechServiceMock(MockBehavior.Loose); this.name = "Name"; this.setCount = 1; this.repetitionCount = 1; }
public WaitWithPromptAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText) { Ensure.ArgumentNotNull(delayService, nameof(delayService)); Ensure.ArgumentNotNull(speechService, nameof(speechService)); Ensure.ArgumentNotNull(promptSpeechText, nameof(promptSpeechText)); Ensure.ArgumentCondition(duration >= TimeSpan.Zero, "duration must be greater than or equal to zero.", nameof(duration)); this.innerAction = new SequenceAction(GetInnerActions(delayService, speechService, duration, promptSpeechText)); }
public RecipeDetailViewModel(ITileService tileService, IDialogService dialogService, IShareService shareService, ISpeechService speechService, INavigationService navigationService) { _liveTileService = tileService; _dialogService = dialogService; _shareService = shareService; _speechService = speechService; _navigationService = navigationService; }
public void AddSpeechClient(String uri) { if (_speech == null) { _speech = new ChannelFactory<ISpeechService>( _binding, new EndpointAddress(_baseUri.ToString() + uri) ).CreateChannel(); } }
public static Parser<SayAction> GetParser(ISpeechService speechService) { Ensure.ArgumentNotNull(speechService, nameof(speechService)); return from _ in Parse.IgnoreCase("say") from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce() from speechText in StringLiteralParser.Parser select new SayAction(speechService, speechText); }
public RecipeDetailViewModel(ILiveTileServiceWP8 tileService, IDialogService dialogService, INavigationService navigationService, IReminderService reminderService, IShareService shareService, ISpeechService speechService) { _liveTileService = tileService; _dialogService = dialogService; _navigationService = navigationService; _reminderService = reminderService; _shareService = shareService; _speechService = speechService; }
public WaitWithPromptAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText) { delayService.AssertNotNull(nameof(delayService)); speechService.AssertNotNull(nameof(speechService)); promptSpeechText.AssertNotNull(nameof(promptSpeechText)); if (duration < TimeSpan.Zero) { throw new ArgumentException("duration must be greater than or equal to zero.", "duration"); } this.innerAction = new SequenceAction(GetInnerActions(delayService, speechService, duration, promptSpeechText)); }
public static IResult<ExercisePrograms> TryParse( string input, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { Ensure.ArgumentNotNull(input, nameof(input)); Ensure.ArgumentNotNull(audioService, nameof(audioService)); Ensure.ArgumentNotNull(delayService, nameof(delayService)); Ensure.ArgumentNotNull(loggerService, nameof(loggerService)); Ensure.ArgumentNotNull(speechService, nameof(speechService)); return ExerciseProgramsParser.GetParser(audioService, delayService, loggerService, speechService).TryParse(input); }
private static IEnumerable<IAction> GetInnerActions(IDelayService delayService, ISpeechService speechService, TimeSpan duration, string promptSpeechText) { yield return new SayAction(speechService, promptSpeechText); if (duration < minimumBreakToIncludeReady) { yield return new WaitAction(delayService, duration); } else { yield return new WaitAction(delayService, duration - minimumBreakToIncludeReady); yield return new SayAction(speechService, "ready?"); yield return new WaitAction(delayService, minimumBreakToIncludeReady); } }
public static IResult<ExercisePrograms> TryParse( string input, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { input.AssertNotNull(nameof(input)); audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); return ExerciseProgramsParser.GetParser(audioService, delayService, loggerService, speechService).TryParse(input); }
public static Parser<ExerciseProgram> GetParser( IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); return from name in HeadingParser.GetParser(1) from _ in Parse.WhiteSpace.Many() from exercises in ExerciseParser.GetParser(audioService, delayService, loggerService, speechService).DelimitedBy(Parse.WhiteSpace.Many()).Optional() select new ExerciseProgram(loggerService, name, exercises.GetOrElse(Enumerable.Empty<Exercise>())); }
public static Parser<ExercisePrograms> GetParser( IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { Ensure.ArgumentNotNull(audioService, nameof(audioService)); Ensure.ArgumentNotNull(delayService, nameof(delayService)); Ensure.ArgumentNotNull(loggerService, nameof(loggerService)); Ensure.ArgumentNotNull(speechService, nameof(speechService)); return from _ in VerticalSeparationParser.Parser from exercisePrograms in ExerciseProgramParser.GetParser(audioService, delayService, loggerService, speechService).DelimitedBy(Parse.WhiteSpace.Many()).Optional() from __ in Parse.WhiteSpace.Many().End() select new ExercisePrograms(exercisePrograms.GetOrElse(Enumerable.Empty<ExerciseProgram>())); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IKioskInteractionService interactionService, ISpeechService speechService, IItemInteractionService manipulationService, IConfigurationProvider configurationProvider) { this.RowWidth = DEPTH_WIDTH; _kioskInteractionService = interactionService; _kioskInteractionService.KioskStateChanged += _kioskInteractionService_KioskStateChanged; _kioskInteractionService.BodyTrackUpdate += _kioskInteractionService_BodyTrackUpdate; BodyTrack = new ObservableCollection<double>() { -75, -75, -75, -75, -75, -75 }; _itemInteractionService = manipulationService; _itemInteractionService.ServiceStateChanged += _itemInteractionService_ServiceStateChanged; _itemInteractionService.ItemInteraction += _itemInteractionService_ItemInteraction; _itemInteractionService.PropertyChanged += _itemInteractionService_PropertyChanged; _speechService = speechService; _speechService.SpeechRecognized += _speechService_SpeechRecognized; _speechService.SpeechRejected += _speechService_SpeechRejected; _speechService.StartListening(); _speechService.Speak("Kiosk Ready"); Messenger.Default.Register<string>(this, (msg) => { if (msg == "SPECIALSTOP") { Debug.WriteLine("MVM SPECIALSTOP " + _lastKioskState); this.KioskState = "CloseSpecial"; } }); this.OpenObjectDetection = new RelayCommand(() => { ShowObjectDetectionWindow(true); }); _configurationProvider = configurationProvider; _configurationProvider.ConfigurationSettingsChanged += _configurationProvider_ConfigurationSettingsChanged; GetConfig(); // Show Object Detection Window on start up ShowObjectDetectionWindow(); }
public static Parser<PrepareAction> GetParser( IDelayService delayService, ISpeechService speechService) { delayService.AssertNotNull(nameof(delayService)); speechService.AssertNotNull(nameof(speechService)); return from _ in Parse.IgnoreCase("prepare") from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce() from ___ in Parse.IgnoreCase("for") from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce() from duration in TimeSpanParser.Parser select new PrepareAction( delayService, speechService, duration); }
public static Parser<BreakAction> GetParser( IDelayService delayService, ISpeechService speechService) { Ensure.ArgumentNotNull(delayService, nameof(delayService)); Ensure.ArgumentNotNull(speechService, nameof(speechService)); return from _ in Parse.IgnoreCase("break") from __ in HorizontalWhitespaceParser.Parser.AtLeastOnce() from ___ in Parse.IgnoreCase("for") from ____ in HorizontalWhitespaceParser.Parser.AtLeastOnce() from duration in TimeSpanParser.Parser select new BreakAction( delayService, speechService, duration); }
public ExerciseProgramsViewModelBuilder() { this.audioService = new AudioServiceMock(MockBehavior.Loose); this.delayService = new DelayServiceMock(MockBehavior.Loose); this.exerciseDocumentService = new ExerciseDocumentServiceMock(MockBehavior.Loose); this.loggerService = new LoggerServiceMock(MockBehavior.Loose); this.schedulerService = new SchedulerServiceMock(MockBehavior.Loose); this.speechService = new SpeechServiceMock(MockBehavior.Loose); this.stateService = new StateServiceMock(MockBehavior.Loose); this.hostScreen = new ScreenMock(MockBehavior.Loose); this.exerciseProgramViewModelFactory = model => new ExerciseProgramViewModelBuilder() .WithModel(model) .Build(); this.WithCachedDocument(null); }
public static Parser<SequenceAction> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel"); Ensure.ArgumentNotNull(audioService, nameof(audioService)); Ensure.ArgumentNotNull(delayService, nameof(delayService)); Ensure.ArgumentNotNull(loggerService, nameof(loggerService)); Ensure.ArgumentNotNull(speechService, nameof(speechService)); return from _ in Parse.IgnoreCase("sequence:") from __ in VerticalSeparationParser.Parser.AtLeastOnce() from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService) select new SequenceAction(actions); }
public static Parser<IEnumerable<IAction>> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel"); Ensure.ArgumentNotNull(audioService, nameof(audioService)); Ensure.ArgumentNotNull(delayService, nameof(delayService)); Ensure.ArgumentNotNull(loggerService, nameof(loggerService)); Ensure.ArgumentNotNull(speechService, nameof(speechService)); return (from _ in Parse.String(" ").Or(Parse.String("\t")).Repeat(indentLevel) from __ in Parse.String("* ") from action in ActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService).Token(HorizontalWhitespaceParser.Parser) select action).DelimitedBy(NewLineParser.Parser); }
public static Parser<IAction> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { Ensure.ArgumentCondition(indentLevel >= 0, "indentLevel must be greater than or equal to 0.", "indentLevel"); Ensure.ArgumentNotNull(audioService, nameof(audioService)); Ensure.ArgumentNotNull(delayService, nameof(delayService)); Ensure.ArgumentNotNull(loggerService, nameof(loggerService)); Ensure.ArgumentNotNull(speechService, nameof(speechService)); return BreakActionParser.GetParser(delayService, speechService) .Or<IAction>(MetronomeActionParser.GetParser(audioService, delayService, loggerService)) .Or<IAction>(PrepareActionParser.GetParser(delayService, speechService)) .Or<IAction>(SayActionParser.GetParser(speechService)) .Or<IAction>(WaitActionParser.GetParser(delayService)) .Or<IAction>(DoNotAwaitActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)) .Or<IAction>(ParallelActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)) .Or<IAction>(SequenceActionParser.GetParser(indentLevel, audioService, delayService, loggerService, speechService)); }
public static Parser<ParallelAction> GetParser( int indentLevel, IAudioService audioService, IDelayService delayService, ILoggerService loggerService, ISpeechService speechService) { if (indentLevel < 0) { throw new ArgumentException("indentLevel must be greater than or equal to 0.", "indentLevel"); } audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); return from _ in Parse.IgnoreCase("parallel:") from __ in VerticalSeparationParser.Parser.AtLeastOnce() from actions in ActionListParser.GetParser(indentLevel + 1, audioService, delayService, loggerService, speechService) select new ParallelAction(actions); }
public MainViewModel(ISpeechService speechService) { _speechService = speechService; }
public BreakAction(IDelayService delayService, ISpeechService speechService, TimeSpan duration) { this.innerAction = new WaitWithPromptAction(delayService, speechService, duration, "break"); }
public MainPageViewModel(IWorkbook workbook, ISynchronizationManager synchronizationManager, IStartupManager startupManager, IMessageBoxService messageBoxService, INotificationService notificationService, INavigationService navigationService, IPlatformService platformService, ITileManager tileManager, ITrackingManager trackingManager, ISpeechService speechService) : base(workbook, synchronizationManager, startupManager, messageBoxService, notificationService, navigationService, platformService, tileManager, trackingManager, speechService) { this.printHelper = new PrintHelper(this.messageBoxService); this.jobScheduler = new AppJobScheduler(this.Workbook, this.synchronizationManager, () => this.MenuItems.OfType <FolderItemViewModel>()); }
static async Task Main(string[] args) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("模式切換方式如下:"); Console.WriteLine("語音輸入模式下,說出 手動輸入 或 切換,即切換為手動輸入模式"); Console.WriteLine("手動輸入模式下,輸入 語音輸入 或 切換,即切換為語音輸入模式"); Console.WriteLine("任一模式下,輸入 關閉 或 結束,即結束應用程式"); Console.ForegroundColor = ConsoleColor.White; // 實體化 語音辨識 服務 speechService = new SpeechService(); // 實體化 語音辨識基本設定用 BM var recognizeBM = new RecognizeBM(); // 要辨識的語言 recognizeBM.Language = "zh-TW"; Console.WriteLine("輸入帳戶金鑰:"); // 取得金鑰 recognizeBM.Subkey = Console.ReadLine(); // 取得服務端點位置,免費試用帳戶都為 westus recognizeBM.Region = "westus"; // 預設程式啟動提示訊息 recognizeBM.Text = "語音服務啟動"; try { // 執行文字轉語音 await speechService.TextToSpeak(recognizeBM); // 用來切換模式的 flag var isTextMode = false; while (true) { if (isTextMode) { Console.WriteLine("手動輸入:"); // 取得輸入文字 recognizeBM.Text = Console.ReadLine(); // 執行文字轉語音 isTextMode = await StartTextToSpeak(recognizeBM, "語音輸入", isTextMode); } else { Console.WriteLine("語音輸入:"); // 取得輸入文字 recognizeBM.Text = await speechService.SpeakToText(recognizeBM); // 執行文字轉語音 isTextMode = await StartTextToSpeak(recognizeBM, "手動輸入", isTextMode); } } } catch { Console.WriteLine("應用程式執行失敗,請重新執行"); Console.ReadLine(); } }