mutablelogic/go-whisper

compile for linux

Closed this issue · 6 comments

Do you have any tips on how to compile for linux? I modified the build command to add GOOS=linux as follows:
@C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GOOS=linux GOARCH=amd64 ${GO} build ${BUILD_FLAGS} -o ${BUILD_DIR}/$(notdir $@) ./$@

image

But compilation fails, im assuming this is because the bindings are not built for linux. Thanks again for sharing your work!

It should work for Linux and Mac. What is the host your are trying to build it on?

I'm working on a mac (intel chip) trying to build for linux

I wonder if CGO gets disabled when you try to cross-compile. I get the same result on Linux if I run the following:

CGO_ENABLED=0 make

Looking at the following article, you'll also need to set the CC variable for the right toolchain for cross-compilation:

https://dh1tw.de/2019/12/cross-compiling-golang-cgo-projects/

You would also need to cross-compile libwhisper.a in the same way. In my humble opinion, you'd be better off compiling directly on a Linux machine or using a hosted version using github actions.

agreed. I'm working on a Dockerfile to build for linux. I will share here in case you want to include it with your repo.

I'm some way off (in this repo) to productionizing the code...but yes please share when you have something. Eventually, "speech to text API" is where I'd like to land this work, but will require integration with ffmpeg API's too to downsample audio to 16Khz mono.

FROM golang:latest
WORKDIR /build
COPY . ./
RUN apt-get update
RUN apt-get install libsdl2-dev --quiet -y
RUN git config --global http.sslverify false
RUN make

you can build with
docker build -t go-whisper:latest .

then copy to your local machine with

docker run --rm -iv$(PWD)/build:/save go-whisper cp -rfp build/stream /save/stream_linux