blob: 933192c95c18cb42b5518df57f92d0b074b507f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<?php
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
namespace OCA\Testing\TaskProcessing;
use OCA\Testing\AppInfo\Application;
use OCP\AppFramework\Services\IAppConfig;
use OCP\Files\File;
use OCP\TaskProcessing\Exception\ProcessingException;
use OCP\TaskProcessing\ISynchronousProvider;
use OCP\TaskProcessing\TaskTypes\AudioToText;
use RuntimeException;
class FakeTranscribeProvider implements ISynchronousProvider {
public function __construct(
protected IAppConfig $appConfig,
) {
}
public function getId(): string {
return Application::APP_ID . '-audio2text';
}
public function getName(): string {
return 'Fake audio2text task processing provider';
}
public function getTaskTypeId(): string {
return AudioToText::ID;
}
public function getExpectedRuntime(): int {
return 1;
}
public function getInputShapeEnumValues(): array {
return [];
}
public function getInputShapeDefaults(): array {
return [];
}
public function getOptionalInputShape(): array {
return [];
}
public function getOptionalInputShapeEnumValues(): array {
return [];
}
public function getOptionalInputShapeDefaults(): array {
return [];
}
public function getOutputShapeEnumValues(): array {
return [];
}
public function getOptionalOutputShape(): array {
return [];
}
public function getOptionalOutputShapeEnumValues(): array {
return [];
}
public function process(?string $userId, array $input, callable $reportProgress): array {
if (!isset($input['input']) || !$input['input'] instanceof File || !$input['input']->isReadable()) {
throw new RuntimeException('Invalid input file');
}
if ($this->appConfig->getAppValueBool('fail-' . $this->getId())) {
throw new ProcessingException('Failing as set by AppConfig');
}
$inputFile = $input['input'];
$transcription = 'Fake transcription result';
return ['output' => $transcription];
}
}
|