ISpeechToTextManager.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\SpeechToText;
  8. use InvalidArgumentException;
  9. use OCP\Files\File;
  10. use OCP\PreConditionNotMetException;
  11. use RuntimeException;
  12. /**
  13. * @since 27.0.0
  14. */
  15. interface ISpeechToTextManager {
  16. /**
  17. * @since 27.0.0
  18. */
  19. public function hasProviders(): bool;
  20. /**
  21. * @return ISpeechToTextProvider[]
  22. * @since 27.1.0
  23. */
  24. public function getProviders(): array;
  25. /**
  26. * Will schedule a transcription process in the background. The result will become available
  27. * with the \OCP\SpeechToText\Events\TranscriptionFinishedEvent
  28. * You should add context information to the context array to re-identify the transcription result as
  29. * belonging to your transcription request.
  30. *
  31. * @param File $file The media file to transcribe
  32. * @param ?string $userId The user that triggered this request (only for convenience, will be available on the TranscriptEvents)
  33. * @param string $appId The app that triggered this request (only for convenience, will be available on the TranscriptEvents)
  34. * @throws PreConditionNotMetException If no provider was registered but this method was still called
  35. * @throws InvalidArgumentException If the file could not be found or is not of a supported type
  36. * @since 27.0.0
  37. */
  38. public function scheduleFileTranscription(File $file, ?string $userId, string $appId): void;
  39. /**
  40. * Will cancel a scheduled transcription process
  41. *
  42. * @param File $file The media file involved in the transcription
  43. * @param ?string $userId The user that triggered this request
  44. * @param string $appId The app that triggered this request
  45. * @throws InvalidArgumentException If the file could not be found or is not of a supported type
  46. * @since 29.0.0
  47. */
  48. public function cancelScheduledFileTranscription(File $file, ?string $userId, string $appId): void;
  49. /**
  50. * @param File $file The media file to transcribe
  51. * @returns string The transcription of the passed media file
  52. * @throws PreConditionNotMetException If no provider was registered but this method was still called
  53. * @throws InvalidArgumentException If the file could not be found or is not of a supported type
  54. * @throws RuntimeException If the transcription failed for other reasons
  55. * @since 27.0.0
  56. */
  57. public function transcribeFile(File $file): string;
  58. }