Class DocumentTranscriptionService

java.lang.Object
org.exoplatform.documents.service.DocumentTranscriptionService

@Service public class DocumentTranscriptionService extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final int
    The longest guest name a speaker can be given, in characters, once trimmed.
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
    Broadcast when a user asks to transcribe a file again, with the user name as source and the file's UUID as data.
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<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).
    boolean
    canNameSpeakers(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).
    boolean
    canRequestRetry(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.
    void
    dismissSpeakerProposal(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.TranscriptionSpeakerCandidates
    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 to MAX_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.TranscriptionState
    getState(String documentId, long aclIdentity)
    The transcription state of a file, read with the user's rights.
    getText(String documentId, long aclIdentity)
    The transcript of a file, read with the user's rights.
    boolean
    Tells whether media files can be transcribed on this server.
    boolean
    requestChapters(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.
    boolean
    requestRetry(String documentId, long aclIdentity, String username)
    Asks to transcribe a file again, for any user who can edit it.
    void
    setGuestSpeaker(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).
    void
    setSpeaker(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 String
    Validates a guest's name, for any caller that stores or proposes one.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 UUID
      aclIdentity - the identity id of the user
      Returns:
      the state
      Throws:
      IllegalAccessException - when the user may not read the file
      org.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 UUID
      aclIdentity - 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 file
      org.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 UUID
      aclIdentity - 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 file
      org.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 UUID
      aclIdentity - 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 file
      org.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 UUID
      aclIdentity - 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 file
      org.exoplatform.commons.exception.ObjectNotFoundException - when the file does not exist or the user cannot see it
    • canNameSpeakers

      public boolean canNameSpeakers(String documentId, long aclIdentity) throws IllegalAccessException
      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 UUID
      aclIdentity - 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 UUID
      speaker - the speaker's number in the transcript
      identityId - the identity id of the person, or null to unname the speaker
      aclIdentity - the identity id of the user naming it
      Throws:
      IllegalAccessException - when the user may not edit the file
      org.exoplatform.commons.exception.ObjectNotFoundException - when the file does not exist or the user cannot see it
      IllegalArgumentException - 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 as TranscriptSpeakers.GUEST_PREFIX followed by the trimmed name, with no escaping: whoever shows it escapes it.
      Parameters:
      documentId - the file's UUID
      speaker - the speaker's number in the transcript
      name - the guest's name
      aclIdentity - the identity id of the user naming it
      Throws:
      IllegalAccessException - when the user may not edit the file
      org.exoplatform.commons.exception.ObjectNotFoundException - when the file does not exist or the user cannot see it
      IllegalArgumentException - when the transcript tells no speakers apart, holds no such speaker, or the name is refused by toGuestName(String)
    • toGuestName

      public static String toGuestName(String name)
      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 than GUEST_NAME_MAX_LENGTH characters 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

      public boolean canRequestRetry(String documentId, long aclIdentity) throws IllegalAccessException
      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 UUID
      aclIdentity - 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 for STALE_TRANSCRIPTION_MILLIS, when its run was lost; a transcribed one is refused.
      Parameters:
      documentId - the file's UUID
      aclIdentity - the identity id of the user
      username - 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 file
      org.exoplatform.commons.exception.ObjectNotFoundException - when the file does not exist or the user cannot see it
      IllegalArgumentException - 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 UUID
      aclIdentity - 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 file
      org.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 to MAX_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 UUID
      suggestions - the proposals, one per speaker at most
      ownerIdentityId - the identity id of the recording's owner, or null when unknown, which names no speaker
      transcriptUpdated - 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 (see premiseHolds(TranscriptionSpeakerSuggestion, Map, List)); an applied one while its speaker is still named after its person.
      Parameters:
      documentId - the file's UUID
      aclIdentity - 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 file
      org.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 UUID
      speaker - the speaker's number in the transcript
      aclIdentity - the identity id of the user
      Throws:
      IllegalAccessException - when the user may not edit the file
      org.exoplatform.commons.exception.ObjectNotFoundException - when the file does not exist or the user cannot see it