Skip to content

Commit 33b7523

Browse files
committed
Fixed bug in speechmatics adapter: Speaker-time was compared as string values, which resulted in wrong speaker assignment in some cases
1 parent 0713129 commit 33b7523

File tree

1 file changed

+5
-3
lines changed
  • packages/stt-adapters/speechmatics

1 file changed

+5
-3
lines changed

packages/stt-adapters/speechmatics/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import generateEntitiesRanges from '../generate-entities-ranges/index.js';
1414
const groupWordsInParagraphs = (words) => {
1515
const results = [];
1616
let paragraph = { words: [], text: [] };
17+
debugger;
1718

1819
words.forEach((word) => {
1920
// if word contains punctuation
@@ -41,7 +42,8 @@ const groupWordsInParagraphs = (words) => {
4142
const getSpeaker = (start, speakers) => {
4243
for (var speakerIdx in speakers) {
4344
const speaker = speakers[speakerIdx];
44-
if (start >= speaker.start & start < speaker.end) {
45+
const segmentStart = parseFloat(start);
46+
if (segmentStart >= speaker.start & segmentStart < speaker.end) {
4547
return speaker.name;
4648
}
4749
}
@@ -89,8 +91,8 @@ const speechmaticsToDraft = (speechmaticsJson) => {
8991
tmpSpeakers = speechmaticsJson.speakers;
9092
tmpSpeakers = tmpSpeakers.map((element) => {
9193
return ({
92-
start: element.time,
93-
end: (parseFloat(element.time) + parseFloat(element.duration)).toString(),
94+
start: parseFloat(element.time),
95+
end: (parseFloat(element.time) + parseFloat(element.duration)),
9496
name: element.name,
9597
});
9698
});

0 commit comments

Comments
 (0)