Browse Source

Merge pull request #43862 from nextcloud/enh/cancel-stt-scheduled-transcription

tags/v29.0.0beta4
John Molakvoæ 2 months ago
parent
commit
77f47ed68f
No account linked to committer's email address

+ 18
- 0
lib/private/SpeechToText/SpeechToTextManager.php View File

@@ -112,6 +112,24 @@ class SpeechToTextManager implements ISpeechToTextManager {
}
}

public function cancelScheduledFileTranscription(File $file, ?string $userId, string $appId): void {
try {
$jobArguments = [
'fileId' => $file->getId(),
'owner' => $file->getOwner()->getUID(),
'userId' => $userId,
'appId' => $appId,
];
if (!$this->jobList->has(TranscriptionJob::class, $jobArguments)) {
$this->logger->debug('Failed to cancel a Speech-to-text job for file ' . $file->getId() . '. No related job was found.');
return;
}
$this->jobList->remove(TranscriptionJob::class, $jobArguments);
} catch (NotFoundException|InvalidPathException $e) {
throw new InvalidArgumentException('Invalid file provided to cancel file transcription: ' . $e->getMessage());
}
}

public function transcribeFile(File $file): string {
if (!$this->hasProviders()) {
throw new PreConditionNotMetException('No SpeechToText providers have been registered');

+ 11
- 0
lib/public/SpeechToText/ISpeechToTextManager.php View File

@@ -61,6 +61,17 @@ interface ISpeechToTextManager {
*/
public function scheduleFileTranscription(File $file, ?string $userId, string $appId): void;

/**
* Will cancel a scheduled transcription process
*
* @param File $file The media file involved in the transcription
* @param ?string $userId The user that triggered this request
* @param string $appId The app that triggered this request
* @throws InvalidArgumentException If the file could not be found or is not of a supported type
* @since 29.0.0
*/
public function cancelScheduledFileTranscription(File $file, ?string $userId, string $appId): void;

/**
* @param File $file The media file to transcribe
* @returns string The transcription of the passed media file

Loading…
Cancel
Save