Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@
FROM golang:1.26.5-alpine AS build

WORKDIR /src

COPY go.mod go.sum* ./
RUN go mod download

COPY . .

ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown

RUN CGO_ENABLED=0 go build -trimpath \
-ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \
-o /out/voicy ./cmd/voicy

FROM alpine:3.22

RUN apk add --no-cache ca-certificates \
&& adduser -D -H -u 10001 voicy

WORKDIR /app

COPY --from=build /out/voicy /app/voicy
COPY migrations /app/migrations

USER voicy

EXPOSE 8080
ENTRYPOINT ["/app/voicy"]

ENTRYPOINT ["/app/voicy"]
16 changes: 2 additions & 14 deletions internal/deepgram/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func isNormalClose(err error) bool {

func (c *Client) ListenFile(ctx context.Context, audio []byte, contentType string) (Result, error) {
if contentType == "" {
contentType = "application/octet-stream"
contentType = "audio/ogg"
}
endpoint := c.rest + ListenPath + "?" + restQuery()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(audio))
Expand All @@ -227,20 +227,8 @@ func (c *Client) ListenFile(ctx context.Context, audio []byte, contentType strin
return ExtractPrerecorded(body)
}

// Transcribe streams first and falls back to the REST Listen endpoint.
func (c *Client) Transcribe(ctx context.Context, audio []byte, contentType string, onPartial func(string)) (Result, error) {
res, err := c.StreamFile(ctx, audio, contentType, onPartial)
if err == nil && strings.TrimSpace(res.Text) != "" {
return res, nil
}
rest, restErr := c.ListenFile(ctx, audio, contentType)
if restErr != nil {
if err != nil {
return Result{}, fmt.Errorf("stream: %v; rest: %w", err, restErr)
}
return Result{}, restErr
}
return rest, nil
return c.ListenFile(ctx, audio, contentType)
}

func redact(key string, err error) error {
Expand Down
Loading