Skip to content

Commit

Permalink
fix - index out of range (#94)
Browse files Browse the repository at this point in the history
* fix - index out of range

* fix - index out of range
  • Loading branch information
fcastillo90 authored May 3, 2023
1 parent fa9d8e0 commit 41b97db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion utils/transcribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,16 @@ func PollTranscription(id string, flags S.TranscribeFlags) {
s.Stop()
return
}

if transcript.Error != nil {
s.Stop()
fmt.Println(*transcript.Error)
return
}
if transcript.Status == nil {
s.Stop()
fmt.Println("Something went wrong. Please try again.")
return
}
if *transcript.Status == "completed" {
s.Stop()
var properties *S.PostHogProperties = new(S.PostHogProperties)
Expand Down
4 changes: 2 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ func GetSentenceTimestamps(sentences []string, words []S.SentimentAnalysisResult
sentenceWords := strings.Split(sentence, " ")
for i := lastIndex; i < len(words); i++ {
if strings.Contains(sentence, words[i].Text) {
if len(words) >= i+2 {
if i < len(words)-2 {
if words[i].Text == sentenceWords[0] && words[i+1].Text == sentenceWords[1] && words[i+2].Text == sentenceWords[2] {
timestamps = append(timestamps, TransformMsToTimestamp(*words[i].Start, false))
lastIndex = i
break
}
} else if len(words) >= i+1 {
} else if i < len(words)-1 {
if words[i].Text == sentenceWords[0] && words[i+1].Text == sentenceWords[1] {
timestamps = append(timestamps, TransformMsToTimestamp(*words[i].Start, false))
lastIndex = i
Expand Down

0 comments on commit 41b97db

Please sign in to comment.