Skip to content

Commit 41b97db

Browse files
authored
fix - index out of range (#94)
* fix - index out of range * fix - index out of range
1 parent fa9d8e0 commit 41b97db

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

utils/transcribe.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,16 @@ func PollTranscription(id string, flags S.TranscribeFlags) {
258258
s.Stop()
259259
return
260260
}
261-
262261
if transcript.Error != nil {
263262
s.Stop()
264263
fmt.Println(*transcript.Error)
265264
return
266265
}
266+
if transcript.Status == nil {
267+
s.Stop()
268+
fmt.Println("Something went wrong. Please try again.")
269+
return
270+
}
267271
if *transcript.Status == "completed" {
268272
s.Stop()
269273
var properties *S.PostHogProperties = new(S.PostHogProperties)

utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,13 @@ func GetSentenceTimestamps(sentences []string, words []S.SentimentAnalysisResult
270270
sentenceWords := strings.Split(sentence, " ")
271271
for i := lastIndex; i < len(words); i++ {
272272
if strings.Contains(sentence, words[i].Text) {
273-
if len(words) >= i+2 {
273+
if i < len(words)-2 {
274274
if words[i].Text == sentenceWords[0] && words[i+1].Text == sentenceWords[1] && words[i+2].Text == sentenceWords[2] {
275275
timestamps = append(timestamps, TransformMsToTimestamp(*words[i].Start, false))
276276
lastIndex = i
277277
break
278278
}
279-
} else if len(words) >= i+1 {
279+
} else if i < len(words)-1 {
280280
if words[i].Text == sentenceWords[0] && words[i+1].Text == sentenceWords[1] {
281281
timestamps = append(timestamps, TransformMsToTimestamp(*words[i].Start, false))
282282
lastIndex = i

0 commit comments

Comments
 (0)