-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor transcription analytics status check (#1951)
- Loading branch information
1 parent
d806061
commit 82568af
Showing
5 changed files
with
145 additions
and
96 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
samples/ingestion/ingestion-client/Connector/Enums/TranscriptionAnalyticsJobStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// <copyright file="TranscriptionAnalyticsJobStatus.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace Connector.Enums | ||
{ | ||
public enum TranscriptionAnalyticsJobStatus | ||
{ | ||
None, | ||
NotStarted, | ||
Running, | ||
Completed | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...n/ingestion-client/FetchTranscription/Extensions/TranscriptionStartedMessageExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// <copyright file="TranscriptionStartedMessageExtensions.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace FetchTranscriptionFunction | ||
{ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
using Connector; | ||
using Connector.Enums; | ||
|
||
using Language; | ||
using Microsoft.Extensions.Logging; | ||
|
||
using TextAnalytics; | ||
|
||
public static class TranscriptionStartedMessageExtensions | ||
{ | ||
public static async Task<TranscriptionAnalyticsJobStatus> GetTranscriptionAnalyticsJobsStatusAsync( | ||
this TranscriptionStartedMessage transcriptionStartedMessage, | ||
TextAnalyticsProvider textAnalyticsProvider, | ||
AnalyzeConversationsProvider analyzeConversationsProvider, | ||
ILogger logger) | ||
{ | ||
_ = transcriptionStartedMessage ?? throw new ArgumentNullException(nameof(transcriptionStartedMessage)); | ||
|
||
if (textAnalyticsProvider == null && analyzeConversationsProvider == null) | ||
{ | ||
return TranscriptionAnalyticsJobStatus.None; | ||
} | ||
|
||
var textAnalyticsRequestCompleted = textAnalyticsProvider != null ? await textAnalyticsProvider.TextAnalyticsRequestsCompleted(transcriptionStartedMessage.AudioFileInfos).ConfigureAwait(false) : true; | ||
var conversationalAnalyticsRequestCompleted = analyzeConversationsProvider != null ? await analyzeConversationsProvider.ConversationalRequestsCompleted(transcriptionStartedMessage.AudioFileInfos).ConfigureAwait(false) : true; | ||
|
||
if (!textAnalyticsRequestCompleted || !conversationalAnalyticsRequestCompleted) | ||
{ | ||
return TranscriptionAnalyticsJobStatus.Running; | ||
} | ||
|
||
// if the message already contains text analytics requests and all are in terminal state, treat jobs as completed: | ||
var containsTextAnalyticsRequest = transcriptionStartedMessage.AudioFileInfos.Where(audioFileInfo => audioFileInfo.TextAnalyticsRequests != null).Any(); | ||
if (containsTextAnalyticsRequest) | ||
{ | ||
return TranscriptionAnalyticsJobStatus.Completed; | ||
} | ||
|
||
return TranscriptionAnalyticsJobStatus.NotStarted; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters