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

Push to production #438

Merged
merged 3 commits into from
Jan 17, 2024
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
4 changes: 2 additions & 2 deletions ClassTranscribeDatabase/CaptionQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public CaptionQueries(CTDbContext context)
/// Get the captions for a given videoId
/// </summary>
/// <param name="language">Language of the captions to fetch.</param>
public async Task<List<Caption>> GetCaptionsAsync(string videoId, string language = "en-US")
public async Task<List<Caption>> GetCaptionsAsync(string videoId, string sourceInternalRef, string language) // = "en-US"
{
try
{
var transcriptionId = _context.Transcriptions.Where(t => t.Language == language && t.VideoId == videoId
var transcriptionId = _context.Transcriptions.Where(t => t.Language == language && t.VideoId == videoId && t.SourceInternalRef== sourceInternalRef
&& t.TranscriptionType == TranscriptionType.Caption).First().Id;
return await GetCaptionsAsync(transcriptionId);
}
Expand Down
5 changes: 3 additions & 2 deletions ClassTranscribeServer/Controllers/EPubsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ public async Task<ActionResult<List<EPubSceneData>>> GetEpubData(string mediaId,
SourceType = ResourceType.Media,
SourceId = mediaId
};

var captions = await _captionQueries.GetCaptionsAsync(media.VideoId, epub.Language);
const string SOURCEINTERNALREF= "ClassTranscribe/Azure"; // Do not change me; this is a key inside the database
// to indicate the source of the captions was this code
var captions = await _captionQueries.GetCaptionsAsync(media.VideoId, SOURCEINTERNALREF, epub.Language);
_logger.LogInformation($"GetEpubData({mediaId}) - returning combined SceneData");

return GetSceneData(sceneArray, captions);
Expand Down
15 changes: 8 additions & 7 deletions TaskEngine/Tasks/TranscriptionTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
{
buildMockCaptions(videoId);
}

const string SOURCEINTERNALREF= "ClassTranscribe/Azure"; // Do not change me; this is a key inside the database
// to indicate the source of the captions was this code


using (var _context = CTDbContext.CreateDbContext())
{
Expand Down Expand Up @@ -165,10 +167,10 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam

foreach (string language in allLanguages)
{
var existing = await _captionQueries.GetCaptionsAsync(video.Id, language);
var existing = await _captionQueries.GetCaptionsAsync(video.Id, SOURCEINTERNALREF, language);
captionsMap[language] = existing;

startAfterMap[language] = TimeSpan.Zero;
startAfterMap[language] = TimeSpan.Zero;
if (existing.Any())
{
TimeSpan lastCaptionTime = existing.Select(c => c.End).Max();
Expand Down Expand Up @@ -196,10 +198,9 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
{
var theLanguage = captionsInLanguage.Key;
var theCaptions = captionsInLanguage.Value;

if (theCaptions.Any())
if (theCaptions.Count>0)
{
var t = _context.Transcriptions.SingleOrDefault(t => t.VideoId == video.Id && t.Language == theLanguage);
var t = _context.Transcriptions.SingleOrDefault(t => t.VideoId == video.Id && t.SourceInternalRef == SOURCEINTERNALREF && t.Language == theLanguage && t.TranscriptionType == TranscriptionType.Caption);
GetLogger().LogInformation($"Find Existing Transcriptions null={t == null}");
// Did we get the default or an existing Transcription entity?
if (t == null)
Expand All @@ -211,7 +212,7 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
Language = theLanguage,
VideoId = video.Id,
Label = $"{theLanguage} (ClassTranscribe)",
SourceInternalRef = "ClassTranscribe/Azure",
SourceInternalRef = SOURCEINTERNALREF, //
SourceLabel = "ClassTranscribe (Azure" + (phraseHints.Length>0 ?" with phrase hints)" : ")")
};
_context.Add(t);
Expand Down
Loading