Skip to content

Commit

Permalink
Merge pull request #438 from classtranscribe/staging
Browse files Browse the repository at this point in the history
Push to production
  • Loading branch information
angrave authored Jan 17, 2024
2 parents 0ef3c37 + ea0018c commit fc32e88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
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

0 comments on commit fc32e88

Please sign in to comment.