Skip to content

Commit

Permalink
Transcript: Use Whisper response without LF. (#163). v5.13.31
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 10, 2024
1 parent fc6ebd1 commit 5ffe4ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
1 change: 1 addition & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ The following are the update records for the SRS Stack server.
* Release stable version and support debugging. [v5.13.28](https://github.com/ossrs/srs-stack/releases/tag/v5.13.28)
* HLS: Set m3u8 expire time to 1s for LLHLS. v5.13.29
* Transcript: Support set the force_style for overlay subtitle. v5.13.30
* Transcript: Use Whisper response without LF. (#163). v5.13.31
* v5.12
* Refine local variable name conf to config. v5.12.1
* Add forced exit on timeout for program termination. v5.12.1
Expand Down
22 changes: 2 additions & 20 deletions platform/transcript.go
Original file line number Diff line number Diff line change
Expand Up @@ -1646,26 +1646,8 @@ func (v *TranscriptTask) DriveAsrQueue(ctx context.Context) error {
srt.WriteString(fmt.Sprintf("%02d:%02d:%02d,%03d\n",
int(e.Hours()), int(e.Minutes())%60, int(e.Seconds())%60, int(e.Milliseconds())%1000))

// Limit each line of text, write a new line if exceed.
lineMaxSize := 45
words := strings.Split(srtSegment.Text, " ")
var current string
for _, word := range words {
if word == "" {
continue
}

if len(current)+len(word) < lineMaxSize {
current += word + " "
continue
}

srt.WriteString(fmt.Sprintf("%v\n", current))
current = word + " "
}
if current != "" {
srt.WriteString(fmt.Sprintf("%v\n", current))
}
// Write the subtitle text.
srt.WriteString(fmt.Sprintf("%v\n", srtSegment.Text))

// Insert a new line.
srt.WriteString("\n")
Expand Down

0 comments on commit 5ffe4ab

Please sign in to comment.