Fix azure ai transcription handler (#931)

* fix azure ai transcription handler

* refactor
This commit is contained in:
an-lee
2024-08-05 11:59:26 +08:00
committed by GitHub
parent 1e6bcab121
commit 8307a16bdc

View File

@@ -387,14 +387,14 @@ export const useTranscribe = () => {
);
reco.stopContinuousRecognitionAsync();
const transcript = results
.map((result) => result.DisplayText)
.join(" ")
.trim();
const timeline: Timeline = [];
results.forEach((result) => {
if (!result.DisplayText) return;
const best = take(sortedUniqBy(result.NBest, "Confidence"), 1)[0];
if (!best.Words) return;
if (!best.Confidence || best.Confidence < 0.5) return;
const firstWord = best.Words[0];
const lastWord = best.Words[best.Words.length - 1];
@@ -407,6 +407,11 @@ export const useTranscribe = () => {
});
});
const transcript = timeline
.map((result) => result.text)
.join(" ")
.trim();
resolve({
engine: "azure",
model: "whisper",