What is causing a discrepancy in the time calculation in Azure's speech service?

35 Views Asked by At

I recently integrated Microsoft's Speech Services into my application. I am doing basic transcribing from mp3 files. In my code, I am logging the duration every time something is transcribed, using this code via Microsoft services:

                using (var audioConfig = AudioConfig.FromWavFileInput(applicationPath + "\\" + tempFilenameAfter))
                {
                    using (var conversationTranscriber = new ConversationTranscriber(speechConfig, audioConfig))
                    {
                        conversationTranscriber.Transcribed += (s, e) =>
                        {
                            //*******AUDIT LOG********
                            string sql = @"INSERT INTO T_TRANSCRIPTIONLOG (OwnerId, CallId, Duration) VALUES (@ownerId,@callId,@duration)";
                            using (IDbConnection db = new SqlConnection(databaseConnectionString))
                            {
                                db.Execute(sql, new { ownerId = ownerId, callId, duration = (int)Math.Ceiling(e.Result.Duration.TotalSeconds) });
                            }

                            if (e.Result.Reason == ResultReason.RecognizedSpeech)
                            {
                                //do my other stuff here...
                            }
                            else if (e.Result.Reason == ResultReason.NoMatch)
                            {
                                logger.LogError($"NOMATCH: Speech could not be transcribed.").Wait();
                            }
                        };
                        await conversationTranscriber.StartTranscribingAsync();
                        Task.WaitAny(new[] { stopRecognition.Task });
                        await conversationTranscriber.StopTranscribingAsync();
                    }
                }

I am simply logging the duration, and rounding up. However, when I look at stats in the Azure instance, the duration that Microsoft shows is slightly higher than what I am logging:

enter image description here

As you can see, the duration that Azure is showing is on average 1.15 times greater than what my logs are showing. Is there any explanation for this? My concern is that in the code above, my logging may not be capturing everything.

0

There are 0 best solutions below