Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit b83e710

Browse files
authored
Merge pull request #56 from AssemblyAI/niels/content-safety
Fix content safety model parsing
2 parents 49503e8 + 16939c4 commit b83e710

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using AssemblyAI.Transcripts;
2+
3+
namespace AssemblyAI.IntegrationTests;
4+
5+
[TestFixture]
6+
public class AudioIntelligenceTests
7+
{
8+
private const string RemoteAudioUrl = "https://assembly.ai/espn.m4a";
9+
10+
[Test]
11+
public async Task ShouldReturnContentSafety()
12+
{
13+
var client = Helpers.CreateClient();
14+
15+
var transcript = await client.Transcripts.TranscribeAsync(new TranscriptParams
16+
{
17+
AudioUrl = RemoteAudioUrl,
18+
ContentSafety = true,
19+
ContentSafetyConfidence = 50,
20+
}
21+
).ConfigureAwait(false);
22+
23+
Assert.That(transcript, Is.Not.Null);
24+
Assert.Multiple(() =>
25+
{
26+
Assert.That(transcript.Id, Is.Not.Null);
27+
Assert.That(transcript.Text, Is.Not.Empty);
28+
Assert.That(transcript.Status, Is.EqualTo(TranscriptStatus.Completed));
29+
Assert.That(transcript.ContentSafetyLabels, Is.Not.Null);
30+
Assert.Multiple(() =>
31+
{
32+
Assert.That(
33+
transcript.ContentSafetyLabels!.Status,
34+
Is.EqualTo(AudioIntelligenceModelStatus.Success)
35+
);
36+
Assert.That(
37+
transcript.ContentSafetyLabels!.Results,
38+
Is.Not.Empty
39+
);
40+
var result = transcript.ContentSafetyLabels!.Results.First();
41+
Assert.That(result.Text, Is.Not.Empty);
42+
Assert.That(result.Labels, Is.Not.Empty);
43+
}
44+
);
45+
});
46+
}
47+
}

src/AssemblyAI/Transcripts/Types/ContentSafetyLabel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public record ContentSafetyLabel
2323
/// How severely the topic is discussed in the section, from 0 to 1
2424
/// </summary>
2525
[JsonPropertyName("severity")]
26-
public required double Severity { get; set; }
26+
public required double? Severity { get; set; }
2727

2828
public override string ToString()
2929
{

0 commit comments

Comments
 (0)