Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transcription Data model fix #39066

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1535,4 +1535,23 @@ public enum TextFormat
{
Display = 0,
}
public partial class TranscriptionData : Azure.Communication.CallAutomation.TranscriptionPackageBase
{
internal TranscriptionData() { }
public double Confidence { get { throw null; } set { } }
public Azure.Communication.CallAutomation.Models.Transcription.TextFormat Format { get { throw null; } set { } }
public ulong Offset { get { throw null; } set { } }
public Azure.Communication.CommunicationUserIdentifier Participant { get { throw null; } set { } }
public Azure.Communication.CallAutomation.Models.Transcription.ResultStatus ResultStatus { get { throw null; } set { } }
public string Text { get { throw null; } set { } }
public System.Collections.Generic.IEnumerable<Azure.Communication.CallAutomation.Models.Transcription.WordData> Words { get { throw null; } set { } }
}
public partial class WordData
{
public WordData() { }
[System.Text.Json.Serialization.JsonPropertyNameAttribute("offset")]
public ulong Offset { get { throw null; } set { } }
[System.Text.Json.Serialization.JsonPropertyNameAttribute("text")]
public string Text { get { throw null; } set { } }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Azure.Communication.CallAutomation.Models.Transcription
/// <summary>
/// Streaming Transcription.
/// </summary>
internal class TranscriptionData : TranscriptionPackageBase
public class TranscriptionData : TranscriptionPackageBase
{
internal TranscriptionData(string text, string format, double confidence, ulong offset, IEnumerable<Word> words, string participantRawID, string resultStatus)
internal TranscriptionData(string text, string format, double confidence, ulong offset, IEnumerable<WordData> words, string participantRawID, string resultStatus)
{
Text = text;
Format = ConvertToTextFormatEnum(format);
Expand Down Expand Up @@ -50,7 +50,7 @@ internal TranscriptionData(string text, string format, double confidence, ulong
/// <summary>
/// The result for each word of the phrase
/// </summary>
public IEnumerable<Word> Words { get; set; }
public IEnumerable<WordData> Words { get; set; }

/// <summary>
/// The identified speaker based on participant raw ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal class TranscriptionDataInternal
/// The result for each word of the phrase
/// </summary>
[JsonPropertyName("words")]
public IEnumerable<Word> Words { get; set; }
public IEnumerable<WordData> Words { get; set; }

/// <summary>
/// The identified speaker based on participant raw ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ public static TranscriptionPackageBase Parse(byte[] receivedBytes)
public static TranscriptionPackageBase Parse(string stringJson)
{
JsonElement package = JsonDocument.Parse(stringJson).RootElement;
if (package.GetProperty("kind").ToString() == "TranscriptionMetadata")

string kind = package.GetProperty("kind").ToString();

if (kind == "TranscriptionMetadata")
{
return JsonSerializer.Deserialize<TranscriptionMetadata>(package.GetProperty("transcriptionMetadata").ToString());
}
else if (package.GetProperty("kind").ToString() == "TranscriptionData")
else if (kind == "TranscriptionData")
{
TranscriptionDataInternal transcriptionDataInternal = JsonSerializer.Deserialize<TranscriptionDataInternal>(
package.GetProperty("transcriptionData").ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

namespace Azure.Communication.CallAutomation.Models.Transcription
{
internal class Word
/// <summary>
/// The result for each word of the phrase
/// </summary>
public class WordData
bharat-kalyan-namburi marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
/// Text in the phrase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static void ValidateTranscriptionData(TranscriptionData transcription)
Assert.AreEqual(1, transcription.Offset);

// validate individual words
IList<Word> words = transcription.Words.ToList();
IList<WordData> words = transcription.Words.ToList();
Assert.AreEqual(2, words.Count);
Assert.AreEqual("Hello", words[0].Text);
Assert.AreEqual(1, words[0].Offset);
Expand Down