public async Task SendTelegramVoiceMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var hookService = new HookService { new (new Command("send-telegram-voice-message"), new Keys(Key.L, Key.RAlt), true), }; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner() ); await using var recognitionService = new RecognitionService(moduleService); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); await hookService.InitializeAsync(cancellationToken); moduleService.Add(new RecognitionServiceRunner(recognitionService)); await Task.Delay(TimeSpan.FromSeconds(15), cancellationToken); }
public async Task TelegramRecordedAndConvertedAudioTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner() ); await using var runnerService = new RunnerService(moduleService); await using var recognitionService = new RecognitionService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); var recognition = await recognitionService.StartAsync(cancellationToken); var bytes = await recognitionService.StartRecordMp3_5Second_Stop_Async(cancellationToken); var preview = await recognition.StopAsync(cancellationToken); await runnerService.RunAsync( new Command("telegram audio", new Value(string.Empty, preview) { Data = bytes, }), cancellationToken); }
public async Task SendTelegramVoiceMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner() ); await using var recognitionService = new RecognitionService(moduleService); await using var runnerService = new RunnerService(moduleService, moduleService, recognitionService); using var exceptions = new IServiceBase[] { moduleService, recognitionService, runnerService }.EnableLogging(cancellationTokenSource); moduleService.Add(new RecognitionServiceRunner(recognitionService)); var process = runnerService.Start(new Command("send-telegram-voice-message"), cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); var value = await process.StopAsync(cancellationToken); Assert.AreNotEqual(0, value.Output.Data.Length); }
public async Task TelegramTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var container = IoCTests.CreateContainer( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner(), TestModules.CreateAliasRunnerCommand("telegram", "телеграмм", "отправь", "отправить") ); using var exceptions = container.EnableLoggingForServices(cancellationTokenSource); await container.Resolve <RecognitionService>().Start_Wait5Seconds_Stop_TestAsync(cancellationToken); }
public async Task BaseTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var container = CreateContainer( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateRunnerWithPrintCommand() ); using var exceptions = container.EnableLoggingForServices(cancellationTokenSource); var recognitionService = container.Resolve <RecognitionService>(); await recognitionService.Start5SecondsStart5SecondsStopTestAsync(cancellationToken); }
public async Task SimpleTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer() ); await using var recognitionService = new RecognitionService(moduleService); using var exceptions = new IServiceBase[] { moduleService, recognitionService }.EnableLogging(cancellationTokenSource); await recognitionService.Start_Wait5Seconds_Stop_TestAsync(cancellationToken); }
public async Task RepeatTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var container = IoCTests.CreateContainer( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateDefaultSynthesizer(), TestModules.CreateDefaultPlayer(), new IntegrationRunner(), TestModules.CreateAliasRunnerCommand("say", "повтори", "повторить", "скажи") ); using var exceptions = container.EnableLoggingForServices(cancellationTokenSource); await container.Resolve <RecognitionService>().Start_Wait5Seconds_Stop_TestAsync(cancellationToken); var runnerService = container.Resolve <RunnerService>(); await runnerService.WaitAllAsync(cancellationToken); }
public async Task TorrentTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(5)); var cancellationToken = cancellationTokenSource.Token; await using var container = IoCTests.CreateContainer( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateDefaultSynthesizer(), TestModules.CreateDefaultPlayer(), TestModules.CreateDefaultSearcher(), new TorrentRunner(), TestModules.CreateRunnerWithPrintCommand(), new IntegrationRunner(), TestModules.CreateAliasRunnerCommand("torrent", "смотреть") ); using var exceptions = container.EnableLoggingForServices(cancellationTokenSource); var recognitionService = container.Resolve <RecognitionService>(); await recognitionService.Start_Wait5Seconds_Stop_TestAsync(cancellationToken); var runnerService = container.Resolve <RunnerService>(); await runnerService.WaitAllAsync(cancellationToken); }