| | | 1 | | // author: https://github.com/pabloFuente |
| | | 2 | | |
| | | 3 | | using System; |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | |
| | | 6 | | namespace LiveKit.Rtc |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents a transcription with multiple segments. |
| | | 10 | | /// </summary> |
| | | 11 | | public class Transcription |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets the participant identity. |
| | | 15 | | /// </summary> |
| | | 16 | | public string ParticipantIdentity { get; } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets the track SID. |
| | | 20 | | /// </summary> |
| | | 21 | | public string TrackSid { get; } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets the transcription segments. |
| | | 25 | | /// </summary> |
| | | 26 | | public IReadOnlyList<Proto.TranscriptionSegment> Segments { get; } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Initializes a new transcription. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <param name="participantIdentity">The participant identity.</param> |
| | | 32 | | /// <param name="trackSid">The track SID.</param> |
| | | 33 | | /// <param name="segments">The transcription segments.</param> |
| | 1 | 34 | | public Transcription( |
| | 1 | 35 | | string participantIdentity, |
| | 1 | 36 | | string trackSid, |
| | 1 | 37 | | IReadOnlyList<Proto.TranscriptionSegment> segments |
| | 1 | 38 | | ) |
| | 1 | 39 | | { |
| | 1 | 40 | | ParticipantIdentity = |
| | 1 | 41 | | participantIdentity ?? throw new ArgumentNullException(nameof(participantIdentity)); |
| | 1 | 42 | | TrackSid = trackSid ?? throw new ArgumentNullException(nameof(trackSid)); |
| | 1 | 43 | | Segments = segments ?? throw new ArgumentNullException(nameof(segments)); |
| | 1 | 44 | | } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Creates a transcription from proto messages. |
| | | 48 | | /// </summary> |
| | | 49 | | internal static Transcription FromProto( |
| | | 50 | | string participantIdentity, |
| | | 51 | | string trackSid, |
| | | 52 | | Google.Protobuf.Collections.RepeatedField<Proto.TranscriptionSegment> segments |
| | | 53 | | ) |
| | 0 | 54 | | { |
| | 0 | 55 | | return new Transcription( |
| | 0 | 56 | | participantIdentity, |
| | 0 | 57 | | trackSid, |
| | 0 | 58 | | new List<Proto.TranscriptionSegment>(segments) |
| | 0 | 59 | | ); |
| | 0 | 60 | | } |
| | | 61 | | } |
| | | 62 | | } |