Public Access
Add meeting assistant speech and summary automation
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace MeetingAssistant.Speakers;
|
||||
|
||||
public sealed class SpeakerIdentity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? CanonicalName { get; set; }
|
||||
|
||||
public int TranscriptionCount { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
public List<SpeakerCandidateName> CandidateNames { get; set; } = [];
|
||||
|
||||
public List<SpeakerAlias> Aliases { get; set; } = [];
|
||||
|
||||
public List<SpeakerSnippet> Snippets { get; set; } = [];
|
||||
|
||||
public string? GetDisplayName()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(CanonicalName))
|
||||
{
|
||||
return CanonicalName;
|
||||
}
|
||||
|
||||
return Aliases
|
||||
.Select(alias => alias.Name)
|
||||
.Where(alias => !string.IsNullOrWhiteSpace(alias))
|
||||
.Order(StringComparer.OrdinalIgnoreCase)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class SpeakerCandidateName
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int SpeakerIdentityId { get; set; }
|
||||
|
||||
public SpeakerIdentity? SpeakerIdentity { get; set; }
|
||||
|
||||
public string Name { get; set; } = "";
|
||||
}
|
||||
|
||||
public sealed class SpeakerSnippet
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int SpeakerIdentityId { get; set; }
|
||||
|
||||
public SpeakerIdentity? SpeakerIdentity { get; set; }
|
||||
|
||||
public byte[] WavBytes { get; set; } = [];
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public sealed class SpeakerAlias
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int SpeakerIdentityId { get; set; }
|
||||
|
||||
public SpeakerIdentity? SpeakerIdentity { get; set; }
|
||||
|
||||
public string Name { get; set; } = "";
|
||||
}
|
||||
|
||||
public sealed class SpeakerIdentityDbContext : DbContext
|
||||
{
|
||||
public SpeakerIdentityDbContext(DbContextOptions<SpeakerIdentityDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<SpeakerIdentity> SpeakerIdentities => Set<SpeakerIdentity>();
|
||||
|
||||
public DbSet<SpeakerCandidateName> SpeakerCandidateNames => Set<SpeakerCandidateName>();
|
||||
|
||||
public DbSet<SpeakerAlias> SpeakerAliases => Set<SpeakerAlias>();
|
||||
|
||||
public DbSet<SpeakerSnippet> SpeakerSnippets => Set<SpeakerSnippet>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<SpeakerIdentity>(entity =>
|
||||
{
|
||||
entity.HasMany(identity => identity.CandidateNames)
|
||||
.WithOne(candidate => candidate.SpeakerIdentity)
|
||||
.HasForeignKey(candidate => candidate.SpeakerIdentityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(identity => identity.Aliases)
|
||||
.WithOne(alias => alias.SpeakerIdentity)
|
||||
.HasForeignKey(alias => alias.SpeakerIdentityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasMany(identity => identity.Snippets)
|
||||
.WithOne(snippet => snippet.SpeakerIdentity)
|
||||
.HasForeignKey(snippet => snippet.SpeakerIdentityId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<SpeakerCandidateName>()
|
||||
.HasIndex(candidate => new { candidate.SpeakerIdentityId, candidate.Name })
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder.Entity<SpeakerAlias>()
|
||||
.HasIndex(alias => new { alias.SpeakerIdentityId, alias.Name })
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user