Skip to content

Commit 5cdc50e

Browse files
committed
Updates and Testing
1 parent 12ee8f2 commit 5cdc50e

9 files changed

Lines changed: 36 additions & 32 deletions

File tree

ClassTranscribeDatabase/CommonUtils.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public enum TaskType
2323
DownloadPlaylistInfo = 3,
2424
DownloadMedia = 4,
2525
ConvertMedia = 5,
26-
TranscribeVideo = 6,
26+
// TranscribeVideo = 6,
2727
ProcessVideo = 7,
2828
Aggregator = 8,
2929
GenerateVTTFile = 9,
@@ -39,7 +39,9 @@ public enum TaskType
3939
PythonCrawler = 19,
4040

4141
DescribeVideo = 20,
42-
DescribeImage = 21
42+
DescribeImage = 21,
43+
AzureTranscribeVideo = 22,
44+
LocalTranscribeVideo = 23
4345

4446
}
4547

ClassTranscribeServer/Controllers/PlaylistsController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public async Task<ActionResult<IEnumerable<PlaylistDTO>>> GetPlaylists2(string o
170170
JsonMetadata = m.JsonMetadata,
171171
CreatedAt = m.CreatedAt,
172172
SceneDetectReady = m.Video.HasSceneObjectData(),
173-
Ready = m.Video != null && "NoError" == m.Video.TranscriptionStatus ,
173+
Ready = m.Video != null && Video.TranscriptionStatusMessages.NOERROR == m.Video.TranscriptionStatus ,
174174
SourceType = m.SourceType,
175175
Duration = m.Video?.Duration,
176176
PublishStatus = m.PublishStatus,
@@ -265,7 +265,7 @@ public async Task<ActionResult<PlaylistDTO>> GetPlaylist(string id)
265265
PublishStatus = m.PublishStatus,
266266
Options = m.GetOptionsAsJson(),
267267
SceneDetectReady = m.Video != null && m.Video.HasSceneObjectData(),
268-
Ready = m.Video != null && "NoError" == m.Video.TranscriptionStatus ,
268+
Ready = m.Video != null && Video.TranscriptionStatusMessages.NOERROR == m.Video.TranscriptionStatus ,
269269
Video = m.Video == null ? null : new VideoDTO
270270
{
271271
Id = m.Video.Id,

ClassTranscribeServer/Utils/WakeDownloader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void TranscribeVideo(string videoOrMediaId, bool deleteExisting)
104104
{
105105
JObject msg = new JObject
106106
{
107-
{ "Type", TaskType.TranscribeVideo.ToString() },
107+
{ "Type", TaskType.LocalTranscribeVideo.ToString() },
108108
{ "videoOrMediaId", videoOrMediaId },
109109
{ "DeleteExisting", deleteExisting }
110110
};

PythonRpcServer/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def serve():
152152
# Until we can ensure no timeouts on remote services, the default here is set to a conservative low number
153153
# This is to ensure we can still make progress even if every python tasks tries to use all cpu cores.
154154
max_workers=int(os.getenv('NUM_PYTHON_WORKERS', 3))
155-
print(f"max_workers={max_workers}")
155+
print(f"max_workers={max_workers}. Starting up grpc server...")
156156

157157
server = grpc.server(futures.ThreadPoolExecutor(max_workers=max_workers))
158158

TaskEngine/Program.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,30 +139,31 @@ static void runQueueAwakerForever() {
139139
// TODO/REVIEW: However some tasks also publish the next items
140140
while (true)
141141
{
142-
// try {
143-
// _logger.LogInformation("Periodic Check");
144-
// queueAwakerTask.Publish(new JObject
145-
// {
146-
// { "Type", TaskType.PeriodicCheck.ToString() }
147-
// });
148-
// } catch (Exception e) {
149-
// _logger.LogError(e, "Error in Periodic Check");
150-
// }
151-
152142
try {
153-
var videoId = "ddceb720-a9d6-417d-b5ea-e94c6c0a86c6";
154-
_logger.LogInformation("Transcription Task Initiated");
143+
_logger.LogInformation("Periodic Check");
155144
queueAwakerTask.Publish(new JObject
156145
{
157-
{ "Type", TaskType.TranscribeVideo.ToString() },
158-
{ "videoOrMediaId", videoId }
146+
{ "Type", TaskType.PeriodicCheck.ToString() }
159147
});
160-
161-
_logger.LogInformation("Transcription Task Published Successfully");
162148
} catch (Exception e) {
163-
_logger.LogError(e, "Error in Transcription Task");
149+
_logger.LogError(e, "Error in Periodic Check");
164150
}
165151

152+
// Hacky testing...
153+
// try {
154+
// var videoId = "ddceb720-a9d6-417d-b5ea-e94c6c0a86c6";
155+
// _logger.LogInformation("Transcription Task Initiated");
156+
// queueAwakerTask.Publish(new JObject
157+
// {
158+
// { "Type", TaskType.LocalTranscribeVideo.ToString() },
159+
// { "videoOrMediaId", videoId }
160+
// });
161+
162+
// _logger.LogInformation("Transcription Task Published Successfully");
163+
// } catch (Exception e) {
164+
// _logger.LogError(e, "Error in Transcription Task");
165+
// }
166+
166167

167168
// Thread.Sleep(timeInterval);
168169
Task.Delay(timeInterval).Wait();
@@ -208,7 +209,7 @@ static void createTaskQueues() {
208209
_serviceProvider.GetService<SceneDetectionTask>().Consume(DISABLED_TASK);
209210

210211
// We dont want concurrency for these tasks
211-
_logger.LogInformation("Creating QueueAwakerTask and Box token tasks consumers.");
212+
_logger.LogInformation("Creating QueueAwakerTask and Box token tasks consumers!");
212213
_serviceProvider.GetService<QueueAwakerTask>().Consume(NO_CONCURRENCY); //TODO TOREVIEW: NO_CONCURRENCY?
213214
// does nothing at the moment _serviceProvider.GetService<UpdateBoxTokenTask>().Consume(NO_CONCURRENCY);
214215
_serviceProvider.GetService<CreateBoxTokenTask>().Consume(NO_CONCURRENCY); // calls _box.CreateAccessTokenAsync(authCode);

TaskEngine/Tasks/AzureTranscriptionTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AzureTranscriptionTask : RabbitMQTask<string>
3232
public AzureTranscriptionTask(RabbitMQConnection rabbitMQ, MSTranscriptionService msTranscriptionService,
3333
// GenerateVTTFileTask generateVTTFileTask,
3434
ILogger<AzureTranscriptionTask> logger, CaptionQueries captionQueries)
35-
: base(rabbitMQ, TaskType.TranscribeVideo, logger)
35+
: base(rabbitMQ, TaskType.AzureTranscribeVideo, logger)
3636
{
3737
_msTranscriptionService = msTranscriptionService;
3838
// nope _generateVTTFileTask = generateVTTFileTask;

TaskEngine/Tasks/LocalTranscriptionTask.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public LocalTranscriptionTask(RabbitMQConnection rabbitMQ,
3636
RpcClient rpcClient,
3737
// GenerateVTTFileTask generateVTTFileTask,
3838
ILogger<LocalTranscriptionTask> logger, CaptionQueries captionQueries)
39-
: base(rabbitMQ, TaskType.TranscribeVideo, logger)
39+
: base(rabbitMQ, TaskType.LocalTranscribeVideo, logger)
4040
{
4141
_rpcClient = rpcClient;
4242
_captionQueries = captionQueries;
@@ -90,16 +90,17 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
9090
GetLogger().LogInformation($"{videoId}: Updated TranscribingAttempts = {video.TranscribingAttempts}");
9191
try
9292
{
93+
var mockWhisperResult = Globals.appSettings.MOCK_RECOGNITION == "MOCK";
9394

94-
GetLogger().LogInformation($"{videoId}: Calling RecognitionWithVideoStreamAsync");
95+
GetLogger().LogInformation($"{videoId}: Calling RecognitionWithVideoStreamAsync( mock={mockWhisperResult})");
9596

9697
var request = new CTGrpc.TranscriptionRequest
9798
{
9899
LogId = videoId,
99100
FilePath = video.Video1.VMPath,
100101
Model = "en",
101102
Language = "en",
102-
Testing = true
103+
Testing = mockWhisperResult
103104
// PhraseHints = phraseHints,
104105
// CourseHints = "",
105106
// OutputLanguages = "en"
@@ -161,7 +162,7 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
161162
{
162163
TranscriptionType = TranscriptionType.Caption,
163164
Captions = theCaptions,
164-
Language = theLanguage,
165+
Language = "en-US" , /* Must be en-US for FrontEnd; Cant be just "en" */
165166
VideoId = video.Id,
166167
Label = $"{theLanguage} (ClassTranscribe)",
167168
SourceInternalRef = SOURCEINTERNALREF, //
@@ -177,7 +178,7 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
177178
}
178179

179180

180-
video.TranscriptionStatus = "NoError";
181+
video.TranscriptionStatus = Video.TranscriptionStatusMessages.NOERROR;
181182
// video.JsonMetadata["LastSuccessfulTime"] = result.LastSuccessTime.ToString();
182183

183184
GetLogger().LogInformation($"{videoId}: Saving captions");

TaskEngine/Tasks/QueueAwakerTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ protected async override Task OnConsume(JObject jObject, TaskParameters taskPara
401401
var sourceId = jObject["SourceId"].ToString();
402402
_pythonCrawlerTask.Publish(sourceId);
403403
}
404-
else if (type == TaskType.TranscribeVideo.ToString())
404+
else if (type == TaskType.LocalTranscribeVideo.ToString())
405405
{
406406
var id = jObject["videoOrMediaId"].ToString();
407407

pythonrpcserver.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
RUN python -m grpc_tools.protoc -I . --python_out=./ --grpc_python_out=./ ct.proto
3232

3333
COPY ./PythonRpcServer .
34-
34+
# The output of this file is used when we set MOCK_RECOGNITION=MOCK for quick testing
3535
RUN whisper -ojf -f transcribe_hellohellohello.wav
3636

3737
CMD [ "nice", "-n", "18", "ionice", "-c", "2", "-n", "6", "python3", "-u", "/PythonRpcServer/server.py" ]

0 commit comments

Comments
 (0)