Class DocumentTranscriptionService
java.lang.Object
org.exoplatform.documents.service.DocumentTranscriptionService
What a user can know and ask about the transcription of an audio or video
file (EXO-92097): its state, its transcript, and a retry. Every read is made
with the user's own rights; the transcription itself is the transcriber's,
which listens to
TRANSCRIPTION_RETRY_REQUESTED_EVENT.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intThe longest guest name a speaker can be given, in characters, once trimmed.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringBroadcast when a user asks to transcribe a file again, with the user name as source and the file's UUID as data.static final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<org.exoplatform.documents.model.TranscriptionSpeakerSuggestion> applySpeakerSuggestions(String documentId, List<org.exoplatform.documents.model.TranscriptionSpeakerSuggestion> suggestions, Long ownerIdentityId, long transcriptUpdated) Keeps the proposals made for the speakers of a recording's transcript, as the system, then names the speakers whose proposal is strong (EXO-92126).booleancanNameSpeakers(String documentId, long aclIdentity) Tells whether a user may say who the speakers of a file's transcript are: anyone who can edit the file (EXO-92123).booleancanRequestRetry(String documentId, long aclIdentity) Tells whether a user may ask to transcribe a file again: anyone who can edit it, as for every other change of its transcript, each run being paid for.voiddismissSpeakerProposal(String documentId, String speaker, long aclIdentity) Dismisses the proposal for one speaker of a file's transcript, for a user who can edit the file (EXO-92126).getChapters(String documentId, long aclIdentity) The chapters a file's transcript is grouped into (EXO-92122), read with the user's rights.getSegments(String documentId, long aclIdentity) The timed segments of a file's transcript, read with the user's rights.org.exoplatform.documents.model.TranscriptionSpeakerCandidatesgetSpeakerCandidates(String documentId) The people who may be the speakers of a recording (EXO-92126): the attendees of its meeting when an add-on knows it; otherwise the file's owner, the users it is shared with one by one and, up toMAX_CANDIDATES, the members of the space that holds it.List<org.exoplatform.documents.model.TranscriptionSpeakerProposal> getSpeakerProposals(String documentId, long aclIdentity) The proposals of who the speakers of a file's transcript are, for a user who can edit the file (EXO-92126), each with the sentences that show it.getSpeakers(String documentId, long aclIdentity) The person each named speaker of a file's transcript is, read with the user's rights (EXO-92123).org.exoplatform.documents.model.TranscriptionStateThe transcription state of a file, read with the user's rights.The transcript of a file, read with the user's rights.booleanTells whether media files can be transcribed on this server.booleanrequestChapters(String documentId, long aclIdentity) Asks for the chapters of a transcript a user opens, for any user who can read the file (EXO-92122): a transcript done before chapters were switched on gets them the first time it is read.booleanrequestRetry(String documentId, long aclIdentity, String username) Asks to transcribe a file again, for any user who can edit it.voidsetGuestSpeaker(String documentId, String speaker, String name, long aclIdentity) Says that a speaker of a file's transcript is a guest with no account, known by a plain name, for anyone who can edit the file (EXO-92123).voidsetSpeaker(String documentId, String speaker, Long identityId, long aclIdentity) Says which person a speaker of a file's transcript is, or that it is nobody named any more, for anyone who can edit the file (EXO-92123).static StringtoGuestName(String name) Validates a guest's name, for any caller that stores or proposes one.
-
Field Details
-
TRANSCRIPTION_RETRY_REQUESTED_EVENT
Broadcast when a user asks to transcribe a file again, with the user name as source and the file's UUID as data.- See Also:
-
UNAVAILABLE_MESSAGE
- See Also:
-
NOT_MEDIA_MESSAGE
- See Also:
-
ALREADY_DONE_MESSAGE
- See Also:
-
NO_SPEAKERS_MESSAGE
- See Also:
-
UNKNOWN_SPEAKER_MESSAGE
- See Also:
-
NOT_A_USER_MESSAGE
- See Also:
-
INVALID_NAME_MESSAGE
- See Also:
-
GUEST_NAME_MAX_LENGTH
public static final int GUEST_NAME_MAX_LENGTHThe longest guest name a speaker can be given, in characters, once trimmed.- See Also:
-
-
Constructor Details
-
DocumentTranscriptionService
public DocumentTranscriptionService()
-
-
Method Details
-
isAvailable
public boolean isAvailable()Tells whether media files can be transcribed on this server.- Returns:
- true when a transcription engine is installed
-
getState
public org.exoplatform.documents.model.TranscriptionState getState(String documentId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException The transcription state of a file, read with the user's rights.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- the state
- Throws:
IllegalAccessException- when the user may not read the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-
getText
public String getText(String documentId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException The transcript of a file, read with the user's rights.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- the transcript, or null when the file has none
- Throws:
IllegalAccessException- when the user may not read the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-
getSegments
public String getSegments(String documentId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException The timed segments of a file's transcript, read with the user's rights.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- the segments as a JSON list, or null when there are none
- Throws:
IllegalAccessException- when the user may not read the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-
getChapters
public String getChapters(String documentId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException The chapters a file's transcript is grouped into (EXO-92122), read with the user's rights.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- the chapters as a JSON list, or null when there are none
- Throws:
IllegalAccessException- when the user may not read the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-
getSpeakers
public Map<String,String> getSpeakers(String documentId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException The person each named speaker of a file's transcript is, read with the user's rights (EXO-92123).- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- the identity id of each named speaker, by speaker number; empty when none is named
- Throws:
IllegalAccessException- when the user may not read the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-
canNameSpeakers
Tells whether a user may say who the speakers of a file's transcript are: anyone who can edit the file (EXO-92123).- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- true when the user can edit the file
- Throws:
IllegalAccessException- when the user's identity cannot be resolved
-
setSpeaker
public void setSpeaker(String documentId, String speaker, Long identityId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Says which person a speaker of a file's transcript is, or that it is nobody named any more, for anyone who can edit the file (EXO-92123). The speaker must be one the transcript holds, and the person an enabled user.- Parameters:
documentId- the file's UUIDspeaker- the speaker's number in the transcriptidentityId- the identity id of the person, or null to unname the speakeraclIdentity- the identity id of the user naming it- Throws:
IllegalAccessException- when the user may not edit the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see itIllegalArgumentException- when the transcript tells no speakers apart, holds no such speaker, or the person is no enabled user
-
setGuestSpeaker
public void setGuestSpeaker(String documentId, String speaker, String name, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Says that a speaker of a file's transcript is a guest with no account, known by a plain name, for anyone who can edit the file (EXO-92123). The name is stored asTranscriptSpeakers.GUEST_PREFIXfollowed by the trimmed name, with no escaping: whoever shows it escapes it.- Parameters:
documentId- the file's UUIDspeaker- the speaker's number in the transcriptname- the guest's nameaclIdentity- the identity id of the user naming it- Throws:
IllegalAccessException- when the user may not edit the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see itIllegalArgumentException- when the transcript tells no speakers apart, holds no such speaker, or the name is refused bytoGuestName(String)
-
toGuestName
Validates a guest's name, for any caller that stores or proposes one.- Parameters:
name- the name as typed- Returns:
- the name, trimmed
- Throws:
IllegalArgumentException- when the name holds no letter or digit, is longer thanGUEST_NAME_MAX_LENGTHcharacters once trimmed, or holds a|, a line break, a control character or a Unicode format character other than the zero-width joiner and non-joiner
-
canRequestRetry
Tells whether a user may ask to transcribe a file again: anyone who can edit it, as for every other change of its transcript, each run being paid for.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- true when the user can edit the file
- Throws:
IllegalAccessException- when the user's identity cannot be resolved
-
requestRetry
public boolean requestRetry(String documentId, long aclIdentity, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Asks to transcribe a file again, for any user who can edit it. A failed file, or one never transcribed, is handed to the transcriber; one queued or being transcribed is left as it is, unless its state has not changed forSTALE_TRANSCRIPTION_MILLIS, when its run was lost; a transcribed one is refused.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the userusername- the user's name- Returns:
- true when the file was handed to the transcriber, false when it was already queued or being transcribed
- Throws:
IllegalAccessException- when the user may not read or edit the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see itIllegalArgumentException- when no transcriber is installed, the file is no audio or video, or it is already transcribed
-
requestChapters
public boolean requestChapters(String documentId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Asks for the chapters of a transcript a user opens, for any user who can read the file (EXO-92122): a transcript done before chapters were switched on gets them the first time it is read. Only a transcript done, with timed segments and no chapters, is handed to the transcriber, which makes them at most once per file and tells whether they are coming.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- true when the chapters are coming: queued now, or queued earlier and not made yet; false when none are to be made
- Throws:
IllegalAccessException- when the user may not read the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-
getSpeakerCandidates
public org.exoplatform.documents.model.TranscriptionSpeakerCandidates getSpeakerCandidates(String documentId) throws org.exoplatform.commons.exception.ObjectNotFoundException The people who may be the speakers of a recording (EXO-92126): the attendees of its meeting when an add-on knows it; otherwise the file's owner, the users it is shared with one by one and, up toMAX_CANDIDATES, the members of the space that holds it. Only enabled users are kept.- Parameters:
documentId- the recording file's UUID- Returns:
- the candidates, and whether they are a meeting's attendees
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist
-
applySpeakerSuggestions
public List<org.exoplatform.documents.model.TranscriptionSpeakerSuggestion> applySpeakerSuggestions(String documentId, List<org.exoplatform.documents.model.TranscriptionSpeakerSuggestion> suggestions, Long ownerIdentityId, long transcriptUpdated) throws org.exoplatform.commons.exception.ObjectNotFoundException Keeps the proposals made for the speakers of a recording's transcript, as the system, then names the speakers whose proposal is strong (EXO-92126). Nothing is kept or named when the transcript changed since the proposals were made from it. A strong proposal names its speaker as the recording's owner, so only while the owner can still edit the file, and only when neither the speaker nor the person is named yet: it never replaces a name a person gave. A proposal made by elimination is never applied, strong or not: a call deletes its guests when it stops, so the voice left over may be a guest's rather than the invited person's. Every proposal is kept, the applied ones marked so, the others shown to the people who can edit the file until one confirms or dismisses them.- Parameters:
documentId- the recording file's UUIDsuggestions- the proposals, one per speaker at mostownerIdentityId- the identity id of the recording's owner, or null when unknown, which names no speakertranscriptUpdated- the update time of the transcription state the proposals were made from, in milliseconds since the epoch- Returns:
- the proposals kept, each saying whether it was applied; none when the transcript changed
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist
-
getSpeakerProposals
public List<org.exoplatform.documents.model.TranscriptionSpeakerProposal> getSpeakerProposals(String documentId, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException The proposals of who the speakers of a file's transcript are, for a user who can edit the file (EXO-92126), each with the sentences that show it. A proposal waiting for a person is shown while neither its speaker nor its person is named, and, for one made by elimination, while what it follows from still holds (seepremiseHolds(TranscriptionSpeakerSuggestion, Map, List)); an applied one while its speaker is still named after its person.- Parameters:
documentId- the file's UUIDaclIdentity- the identity id of the user- Returns:
- the proposals to show, in the order they were made
- Throws:
IllegalAccessException- when the user may not edit the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-
dismissSpeakerProposal
public void dismissSpeakerProposal(String documentId, String speaker, long aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Dismisses the proposal for one speaker of a file's transcript, for a user who can edit the file (EXO-92126).- Parameters:
documentId- the file's UUIDspeaker- the speaker's number in the transcriptaclIdentity- the identity id of the user- Throws:
IllegalAccessException- when the user may not edit the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not exist or the user cannot see it
-