Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ For limit that you can control:

* `SRS_FORWARD_LIMIT`: The limit for SRS forward. Default: `10`.
* `SRS_VLIVE_LIMIT`: The limit for SRS virtual live. Default: `10`.
* `SRS_TRANSCRIPT_FIX_QUEUE_LIMIT`: The limit for SRS transcript manually fix queue. Default: `2`.
* `SRS_TRANSCRIPT_OVERLAY_QUEUE_LIMIT`: The limit for SRS transcript overlay queue. Default: `9`.

For feature control:

Expand Down
15 changes: 14 additions & 1 deletion platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -132,13 +133,24 @@ func doMain(ctx context.Context) error {
setEnvDefault("SRS_VLIVE_LIMIT", "10")
setEnvDefault("SRS_CAMERA_LIMIT", "10")

// For transcript queue limit.
setEnvDefault("SRS_TRANSCRIPT_FIX_QUEUE_LIMIT", "2")
if _, err := strconv.ParseInt(envTranscriptFixQueueLimit(), 10, 64); err != nil {
return errors.Wrapf(err, "parse env transcript fix queue limit %v", envTranscriptFixQueueLimit())
}
setEnvDefault("SRS_TRANSCRIPT_OVERLAY_QUEUE_LIMIT", "9")
if _, err := strconv.ParseInt(envTranscriptOverlayQueueLimit(), 10, 64); err != nil {
return errors.Wrapf(err, "parse env transcript overlay queue limit %v", envTranscriptOverlayQueueLimit())
}

logger.Tf(ctx, "load .env as MGMT_PASSWORD=%vB, GO_PPROF=%v, "+
"SRS_PLATFORM_SECRET=%vB, CLOUD=%v, REGION=%v, SOURCE=%v, SRT_PORT=%v, RTC_PORT=%v, "+
"NODE_ENV=%v, LOCAL_RELEASE=%v, REDIS_DATABASE=%v, REDIS_HOST=%v, REDIS_PASSWORD=%vB, REDIS_PORT=%v, RTMP_PORT=%v, "+
"PUBLIC_URL=%v, BUILD_PATH=%v, REACT_APP_LOCALE=%v, PLATFORM_LISTEN=%v, HTTP_PORT=%v, "+
"REGISTRY=%v, MGMT_LISTEN=%v, HTTPS_LISTEN=%v, AUTO_SELF_SIGNED_CERTIFICATE=%v, "+
"NAME_LOOKUP=%v, PLATFORM_DOCKER=%v, SRS_FORWARD_LIMIT=%v, SRS_VLIVE_LIMIT=%v, "+
"SRS_CAMERA_LIMIT=%v, YTDL_PROXY=%v",
"SRS_CAMERA_LIMIT=%v, YTDL_PROXY=%v"+
"SRS_TRANSCRIPT_FIX_QUEUE_LIMIT=%v, SRS_TRANSCRIPT_OVERLAY_QUEUE_LIMIT=%v",
len(envMgmtPassword()), envGoPprof(), len(envApiSecret()), envCloud(),
envRegion(), envSource(), envSrtListen(), envRtcListen(),
envNodeEnv(), envLocalRelease(),
Expand All @@ -149,6 +161,7 @@ func doMain(ctx context.Context) error {
envSelfSignedCertificate(), envNameLookup(),
envPlatformDocker(), envForwardLimit(), envVLiveLimit(),
envCameraLimit(), envYtdlProxy(),
envTranscriptFixQueueLimit(), envTranscriptOverlayQueueLimit(),
)

// Start the Go pprof if enabled.
Expand Down
28 changes: 20 additions & 8 deletions platform/transcript.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import (
"github.com/sashabaranov/go-openai"
)

// The total segments in overlay HLS.
const maxOverlaySegments = 9

var transcriptWorker *TranscriptWorker

type TranscriptWorker struct {
Expand Down Expand Up @@ -1717,8 +1714,11 @@ func (v *TranscriptTask) DriveLiveQueue(ctx context.Context) error {
return nil
}

// Get total segments in overlay HLS.
maxOverlaySegments, _ := strconv.ParseInt(envTranscriptOverlayQueueLimit(), 10, 64)

// Wait if ASR queue is full.
if v.AsrQueue.count() >= maxOverlaySegments+1 {
if v.AsrQueue.count() >= int(maxOverlaySegments)+1 {
Comment thread Fixed
return nil
}

Expand Down Expand Up @@ -1792,8 +1792,11 @@ func (v *TranscriptTask) DriveAsrQueue(ctx context.Context) error {
return nil
}

// Get total segments in overlay HLS.
maxOverlaySegments, _ := strconv.ParseInt(envTranscriptOverlayQueueLimit(), 10, 64)

// Wait if Fix queue is full.
if v.FixQueue.count() >= maxOverlaySegments+1 {
if v.FixQueue.count() >= int(maxOverlaySegments)+1 {
Comment thread Fixed
return nil
}

Expand Down Expand Up @@ -1917,8 +1920,11 @@ func (v *TranscriptTask) DriveFixQueue(ctx context.Context) error {
return nil
}

// Get total segments in manually fix queue.
maxFixQueueLimit, _ := strconv.ParseInt(envTranscriptFixQueueLimit(), 10, 64)

// Ignore if not enough segments.
if v.FixQueue.count() <= 2 {
if v.FixQueue.count() <= int(maxFixQueueLimit) {
Comment thread Fixed
return nil
}

Expand All @@ -1937,8 +1943,11 @@ func (v *TranscriptTask) DriveFixQueue(ctx context.Context) error {
return nil
}

// Get total segments in overlay HLS.
maxOverlaySegments, _ := strconv.ParseInt(envTranscriptOverlayQueueLimit(), 10, 64)

// Wait if Overlay queue is full.
if v.OverlayQueue.count() >= maxOverlaySegments+1 {
if v.OverlayQueue.count() >= int(maxOverlaySegments)+1 {
Comment thread Fixed
return nil
}

Expand Down Expand Up @@ -2028,8 +2037,11 @@ func (v *TranscriptTask) DriveOverlayQueue(ctx context.Context) error {
return nil
}

// Get total segments in overlay HLS.
maxOverlaySegments, _ := strconv.ParseInt(envTranscriptOverlayQueueLimit(), 10, 64)

// Ignore if not enough segments.
if v.OverlayQueue.count() <= maxOverlaySegments {
if v.OverlayQueue.count() <= int(maxOverlaySegments) {
Comment thread Fixed
select {
case <-ctx.Done():
case <-time.After(1 * time.Second):
Expand Down
8 changes: 8 additions & 0 deletions platform/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,14 @@ func envYtdlProxy() string {
return os.Getenv("YTDL_PROXY")
}

func envTranscriptFixQueueLimit() string {
return os.Getenv("SRS_TRANSCRIPT_FIX_QUEUE_LIMIT")
}

func envTranscriptOverlayQueueLimit() string {
return os.Getenv("SRS_TRANSCRIPT_OVERLAY_QUEUE_LIMIT")
}

// rdb is a global redis client object.
var rdb *redis.Client

Expand Down