Skip to content

Commit 8e607a0

Browse files
authored
Merge pull request #56 from mutablelogic/main
Sync branches
2 parents eb84f09 + e61bc83 commit 8e607a0

File tree

5 files changed

+35
-48
lines changed

5 files changed

+35
-48
lines changed

Makefile

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,18 @@ ifeq ($(GGML_CUDA),1)
3030
endif
3131

3232
# Targets
33-
all: server cli
33+
all: whisper
3434

3535
# Generate the pkg-config files
3636
generate: mkdir go-tidy
3737
@echo "Generating pkg-config"
3838
@PKG_CONFIG_PATH=${ROOT_PATH}/${BUILD_DIR} go generate ./sys/whisper
3939

40-
# Make server
41-
server: mkdir generate go-tidy libwhisper libggml
40+
# Make whisper
41+
whisper: mkdir generate go-tidy libwhisper libggml
4242
@echo "Building whisper"
4343
@PKG_CONFIG_PATH=${ROOT_PATH}/${BUILD_DIR} ${GO} build ${BUILD_FLAGS} -o ${BUILD_DIR}/whisper ./cmd/whisper
4444

45-
# Make cli
46-
cli: mkdir generate go-tidy
47-
@echo "Building whisper-cli"
48-
@PKG_CONFIG_PATH=${ROOT_PATH}/${BUILD_DIR} ${GO} build ${BUILD_FLAGS} -o ${BUILD_DIR}/whisper-cli ./cmd/cli
49-
5045
# Build docker container
5146
docker: docker-dep submodule
5247
@echo build docker image: ${BUILD_TAG} for ${OS}/${ARCH}
@@ -75,11 +70,6 @@ libggml: submodule
7570
@echo "Building libggml.a"
7671
@cd third_party/whisper.cpp && make -j$(nproc) libggml.a
7772

78-
# Build whisper-server
79-
whisper-server: submodule
80-
@echo "Building whisper-server"
81-
@cd third_party/whisper.cpp && make -j$(nproc) server
82-
8373
# Push docker container
8474
docker-push: docker-dep
8575
@echo push docker image: ${BUILD_TAG}

etc/Dockerfile.linux-amd64

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ RUN make -j$(nproc) server
3232
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
3333
ARG CUDA_MAIN_VERSION=12.5
3434
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install libgomp1
35-
COPY --from=build /app/build/whisper-server /usr/local/bin/whisper-server
35+
COPY --from=build /app/build/whisper /usr/local/bin/whisper
3636
ENV LD_LIBRARY_PATH=/usr/local/cuda-${CUDA_MAIN_VERSION}/compat:$LD_LIBRARY_PATH
3737

3838
# Expose
39-
ENTRYPOINT [ "/usr/local/bin/whisper-server" ]
39+
ENTRYPOINT [ "/usr/local/bin/whisper" ]
40+
CMD [ "server", "--dir=/data" ]

etc/Dockerfile.linux-arm64

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ RUN make -j$(nproc) server
3232
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
3333
ARG CUDA_MAIN_VERSION=12.2
3434
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install libgomp1
35-
COPY --from=build /app/build/whisper-server /usr/local/bin/whisper-server
35+
COPY --from=build /app/build/whisper /usr/local/bin/whisper
3636
ENV LD_LIBRARY_PATH=/usr/local/cuda-${CUDA_MAIN_VERSION}/compat:$LD_LIBRARY_PATH
3737

3838
# Expose
39-
ENTRYPOINT [ "/usr/local/bin/whisper-server" ]
39+
ENTRYPOINT [ "/usr/local/bin/whisper" ]
40+
CMD [ "server", "--dir=/data" ]

pkg/whisper/api/register.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
func RegisterEndpoints(base string, mux *http.ServeMux, whisper *whisper.Whisper) {
1616
// Health: GET /v1/health
1717
// returns an empty OK response
18-
mux.HandleFunc(joinPath(base, "health"), wrapLogging(func(w http.ResponseWriter, r *http.Request) {
18+
mux.HandleFunc(joinPath(base, "health"), func(w http.ResponseWriter, r *http.Request) {
1919
defer r.Body.Close()
2020

2121
switch r.Method {
@@ -24,14 +24,14 @@ func RegisterEndpoints(base string, mux *http.ServeMux, whisper *whisper.Whisper
2424
default:
2525
httpresponse.Error(w, http.StatusMethodNotAllowed)
2626
}
27-
}))
27+
})
2828

2929
// List Models: GET /v1/models
3030
// returns available models
3131
// Download Model: POST /v1/models?stream={bool}
3232
// downloads a model from the server
3333
// if stream is true then progress is streamed back to the client
34-
mux.HandleFunc(joinPath(base, "models"), wrapLogging(func(w http.ResponseWriter, r *http.Request) {
34+
mux.HandleFunc(joinPath(base, "models"), func(w http.ResponseWriter, r *http.Request) {
3535
defer r.Body.Close()
3636

3737
switch r.Method {
@@ -42,13 +42,13 @@ func RegisterEndpoints(base string, mux *http.ServeMux, whisper *whisper.Whisper
4242
default:
4343
httpresponse.Error(w, http.StatusMethodNotAllowed)
4444
}
45-
}))
45+
})
4646

4747
// Get: GET /v1/models/{id}
4848
// returns an existing model
4949
// Delete: DELETE /v1/models/{id}
5050
// deletes an existing model
51-
mux.HandleFunc(joinPath(base, "models/{id}"), wrapLogging(func(w http.ResponseWriter, r *http.Request) {
51+
mux.HandleFunc(joinPath(base, "models/{id}"), func(w http.ResponseWriter, r *http.Request) {
5252
defer r.Body.Close()
5353

5454
id := r.PathValue("id")
@@ -60,12 +60,12 @@ func RegisterEndpoints(base string, mux *http.ServeMux, whisper *whisper.Whisper
6060
default:
6161
httpresponse.Error(w, http.StatusMethodNotAllowed)
6262
}
63-
}))
63+
})
6464

6565
// Translate: POST /v1/audio/translations
6666
// Translates audio into english or another language - language parameter should be set to the
6767
// destination language of the audio. Will default to english if not set.
68-
mux.HandleFunc(joinPath(base, "audio/translations"), wrapLogging(func(w http.ResponseWriter, r *http.Request) {
68+
mux.HandleFunc(joinPath(base, "audio/translations"), func(w http.ResponseWriter, r *http.Request) {
6969
defer r.Body.Close()
7070

7171
switch r.Method {
@@ -74,12 +74,12 @@ func RegisterEndpoints(base string, mux *http.ServeMux, whisper *whisper.Whisper
7474
default:
7575
httpresponse.Error(w, http.StatusMethodNotAllowed)
7676
}
77-
}))
77+
})
7878

7979
// Transcribe: POST /v1/audio/transcriptions
8080
// Transcribes audio into the input language - language parameter should be set to the source
8181
// language of the audio
82-
mux.HandleFunc(joinPath(base, "audio/transcriptions"), wrapLogging(func(w http.ResponseWriter, r *http.Request) {
82+
mux.HandleFunc(joinPath(base, "audio/transcriptions"), func(w http.ResponseWriter, r *http.Request) {
8383
defer r.Body.Close()
8484

8585
switch r.Method {
@@ -102,21 +102,22 @@ func RegisterEndpoints(base string, mux *http.ServeMux, whisper *whisper.Whisper
102102
default:
103103
httpresponse.Error(w, http.StatusMethodNotAllowed)
104104
}
105-
}))
105+
})
106106

107107
// Transcribe: POST /v1/audio/transcriptions/{model-id}
108108
// Transcribes streamed media into the input language
109-
mux.HandleFunc(joinPath(base, "audio/transcriptions/{model}"), wrapLogging(func(w http.ResponseWriter, r *http.Request) {
110-
defer r.Body.Close()
111-
112-
model := r.PathValue("model")
113-
switch r.Method {
114-
case http.MethodPost:
115-
TranscribeStream(r.Context(), whisper, w, r, model)
116-
default:
117-
httpresponse.Error(w, http.StatusMethodNotAllowed)
118-
}
119-
}))
109+
/*
110+
mux.HandleFunc(joinPath(base, "audio/transcriptions/{model}"), func(w http.ResponseWriter, r *http.Request) {
111+
defer r.Body.Close()
112+
113+
model := r.PathValue("model")
114+
switch r.Method {
115+
case http.MethodPost:
116+
TranscribeStream(r.Context(), whisper, w, r, model)
117+
default:
118+
httpresponse.Error(w, http.StatusMethodNotAllowed)
119+
}
120+
})*/
120121
}
121122

122123
/////////////////////////////////////////////////////////////////////////////

pkg/whisper/api/transcribe.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,8 @@ func TranscribeFile(ctx context.Context, service *whisper.Whisper, w http.Respon
163163

164164
// TODO: Set temperature, etc
165165

166-
// Create response
167-
result = task.Result()
168-
result.Task = "transcribe"
169-
if translate {
170-
result.Task = "translate"
171-
}
172-
result.Language = task.Language()
173-
174166
// Output the header
167+
result.Language = taskctx.Language()
175168
if stream != nil {
176169
stream.Write("task", taskctx.Result())
177170
}
@@ -203,8 +196,7 @@ func TranscribeFile(ctx context.Context, service *whisper.Whisper, w http.Respon
203196
}
204197

205198
// Set the language and duration
206-
result.Language = task.Language()
207-
result.Duration = schema.Timestamp(segmenter.Duration())
199+
result.Language = taskctx.Language()
208200

209201
// Return success
210202
return nil
@@ -225,6 +217,7 @@ func TranscribeFile(ctx context.Context, service *whisper.Whisper, w http.Respon
225217
}
226218
}
227219

220+
/*
228221
func TranscribeStream(ctx context.Context, service *whisper.Whisper, w http.ResponseWriter, r *http.Request, modelId string) {
229222
var query queryTranscribe
230223
if err := httprequest.Query(&query, r.URL.Query()); err != nil {
@@ -331,6 +324,7 @@ func TranscribeStream(ctx context.Context, service *whisper.Whisper, w http.Resp
331324
}
332325
}
333326
}
327+
*/
334328

335329
///////////////////////////////////////////////////////////////////////////////
336330
// PRIVATE METHODS

0 commit comments

Comments
 (0)