Beispiel #1
0
        public static async Task Start5SecondsStart5SecondsStopTestAsync(
            this RecognitionService service,
            CancellationToken cancellationToken = default)
        {
            await service.StartAsync(cancellationToken);

            await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);

            await service.StartAsync(cancellationToken);

            await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);

            await service.StopAsync(cancellationToken);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public static async Task Start_Wait5Seconds_Stop_TestAsync(
            this RecognitionService service,
            CancellationToken cancellationToken = default)
        {
            using var recognition = await service.StartAsync(cancellationToken);

            await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);

            await recognition.StopAsync(cancellationToken);
        }