mirror of https://github.com/nextcloud/server
feat(stt): add ability to cancel a scheduled transcription
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
parent
df1cd1ba7e
commit
76925f15d6
|
@ -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');
|
||||
|
|
|
@ -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…
Reference in New Issue