Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0df27901c9 | |||
| a5b66c09c3 | |||
| c668802b15 |
@@ -3,10 +3,13 @@ FROM golang:1.25-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk add --no-cache ca-certificates
|
||||
RUN apk add --no-cache ca-certificates git
|
||||
|
||||
ENV GOPRIVATE=git.daviestechlabs.io
|
||||
ENV GONOSUMCHECK=git.daviestechlabs.io
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
RUN --mount=type=secret,id=netrc,target=/root/.netrc go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
|
||||
6
go.mod
6
go.mod
@@ -3,9 +3,9 @@ module git.daviestechlabs.io/daviestechlabs/stt-module
|
||||
go 1.25.1
|
||||
|
||||
require (
|
||||
git.daviestechlabs.io/daviestechlabs/handler-base v0.1.3
|
||||
git.daviestechlabs.io/daviestechlabs/handler-base v1.0.0
|
||||
github.com/nats-io/nats.go v1.48.0
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1
|
||||
google.golang.org/protobuf v1.36.11
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -19,7 +19,6 @@ require (
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.11 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/otel v1.40.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.40.0 // indirect
|
||||
@@ -37,5 +36,4 @@ require (
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
|
||||
google.golang.org/grpc v1.78.0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
)
|
||||
|
||||
8
go.sum
8
go.sum
@@ -1,5 +1,5 @@
|
||||
git.daviestechlabs.io/daviestechlabs/handler-base v0.1.3 h1:uYog8B839ulqrWoht3qqCvT7CnR3e2skpaLZc2Pg3GI=
|
||||
git.daviestechlabs.io/daviestechlabs/handler-base v0.1.3/go.mod h1:M3HgvUDWnRn7cX3BE8l+HvoCUYtmRr5OoumB+hnRHoE=
|
||||
git.daviestechlabs.io/daviestechlabs/handler-base v1.0.0 h1:pB3ehOKaDYQfbyRBKQXrB9curqSFteLrDveoElRKnBY=
|
||||
git.daviestechlabs.io/daviestechlabs/handler-base v1.0.0/go.mod h1:zocOHFt8yY3cW4+Xi37sNr5Tw7KcjGFSZqgWYxPWyqA=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
@@ -33,10 +33,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
||||
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms=
|
||||
|
||||
24
main.go
24
main.go
@@ -20,7 +20,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"git.daviestechlabs.io/daviestechlabs/handler-base/config"
|
||||
"git.daviestechlabs.io/daviestechlabs/handler-base/health"
|
||||
@@ -324,17 +324,17 @@ func main() {
|
||||
|
||||
if transcript != "" {
|
||||
result := &messages.STTTranscription{
|
||||
SessionID: sessionID,
|
||||
SessionId: sessionID,
|
||||
Transcript: transcript,
|
||||
Sequence: seq,
|
||||
Sequence: int32(seq),
|
||||
IsPartial: !complete,
|
||||
IsFinal: complete,
|
||||
Timestamp: time.Now().Unix(),
|
||||
SpeakerID: speakerID,
|
||||
SpeakerId: speakerID,
|
||||
HasVoiceActivity: hasVoice,
|
||||
State: state,
|
||||
}
|
||||
packed, _ := msgpack.Marshal(result)
|
||||
packed, _ := proto.Marshal(result)
|
||||
_ = nc.Conn().Publish(fmt.Sprintf("%s.%s", transcriptionSubjectPrefix, sessionID), packed)
|
||||
slog.Info("published transcription", "session", sessionID, "seq", seq)
|
||||
}
|
||||
@@ -378,8 +378,8 @@ func main() {
|
||||
}
|
||||
sessionID := parts[3]
|
||||
|
||||
streamMsg, err := natsutil.Decode[messages.STTStreamMessage](natMsg.Data)
|
||||
if err != nil {
|
||||
var streamMsg messages.STTStreamMessage
|
||||
if err := natsutil.Decode(natMsg.Data, &streamMsg); err != nil {
|
||||
slog.Error("decode error", "error", err)
|
||||
return
|
||||
}
|
||||
@@ -391,8 +391,8 @@ func main() {
|
||||
if streamMsg.State != "" {
|
||||
buf.setState(streamMsg.State)
|
||||
}
|
||||
if streamMsg.SpeakerID != "" {
|
||||
buf.speakerID = streamMsg.SpeakerID
|
||||
if streamMsg.SpeakerId != "" {
|
||||
buf.speakerID = streamMsg.SpeakerId
|
||||
}
|
||||
sessionsMu.Lock()
|
||||
sessions[sessionID] = buf
|
||||
@@ -442,12 +442,12 @@ func main() {
|
||||
// Check for interrupt
|
||||
if buffer.checkInterrupt(streamMsg.Audio, enableInterrupt, audioLevelThreshold, interruptDuration) {
|
||||
interruptMsg := &messages.STTInterrupt{
|
||||
SessionID: sessionID,
|
||||
SessionId: sessionID,
|
||||
Type: "interrupt",
|
||||
Timestamp: time.Now().Unix(),
|
||||
SpeakerID: buffer.speakerID,
|
||||
SpeakerId: buffer.speakerID,
|
||||
}
|
||||
packed, _ := msgpack.Marshal(interruptMsg)
|
||||
packed, _ := proto.Marshal(interruptMsg)
|
||||
_ = nc.Conn().Publish(fmt.Sprintf("%s.%s", transcriptionSubjectPrefix, sessionID), packed)
|
||||
slog.Info("published interrupt", "session", sessionID)
|
||||
buffer.setState(stateListening)
|
||||
|
||||
Reference in New Issue
Block a user