1
0

FakeTranscribeProvider.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. declare(strict_types=1);
  7. namespace OCA\Testing\TaskProcessing;
  8. use OCA\Testing\AppInfo\Application;
  9. use OCP\Files\File;
  10. use OCP\TaskProcessing\ISynchronousProvider;
  11. use OCP\TaskProcessing\TaskTypes\AudioToText;
  12. use RuntimeException;
  13. class FakeTranscribeProvider implements ISynchronousProvider {
  14. public function __construct(
  15. ) {
  16. }
  17. public function getId(): string {
  18. return Application::APP_ID . '-audio2text';
  19. }
  20. public function getName(): string {
  21. return 'Fake audio2text task processing provider';
  22. }
  23. public function getTaskTypeId(): string {
  24. return AudioToText::ID;
  25. }
  26. public function getExpectedRuntime(): int {
  27. return 1;
  28. }
  29. public function getInputShapeEnumValues(): array {
  30. return [];
  31. }
  32. public function getInputShapeDefaults(): array {
  33. return [];
  34. }
  35. public function getOptionalInputShape(): array {
  36. return [];
  37. }
  38. public function getOptionalInputShapeEnumValues(): array {
  39. return [];
  40. }
  41. public function getOptionalInputShapeDefaults(): array {
  42. return [];
  43. }
  44. public function getOutputShapeEnumValues(): array {
  45. return [];
  46. }
  47. public function getOptionalOutputShape(): array {
  48. return [];
  49. }
  50. public function getOptionalOutputShapeEnumValues(): array {
  51. return [];
  52. }
  53. public function process(?string $userId, array $input, callable $reportProgress): array {
  54. if (!isset($input['input']) || !$input['input'] instanceof File || !$input['input']->isReadable()) {
  55. throw new RuntimeException('Invalid input file');
  56. }
  57. $inputFile = $input['input'];
  58. $transcription = 'Fake transcription result';
  59. return ['output' => $transcription];
  60. }
  61. }