From ecccb9d523dbf5d1d65a8021aa28d29c0662d5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Mon, 6 Mar 2023 20:46:18 +0100 Subject: [PATCH 01/27] updated bindings to latest build of whisper.cpp --- whisper.cpp | 2 +- whispercpp.pxd | 2 +- whispercpp.pyx | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/whisper.cpp b/whisper.cpp index 1d716d6..b597c5a 160000 --- a/whisper.cpp +++ b/whisper.cpp @@ -1 +1 @@ -Subproject commit 1d716d6e34f3f4ba57bd9706a9258a0bdb008153 +Subproject commit b597c5a779e1086bded7d06e0f46112b2f688989 diff --git a/whispercpp.pxd b/whispercpp.pxd index 1a033db..d37205c 100644 --- a/whispercpp.pxd +++ b/whispercpp.pxd @@ -71,7 +71,7 @@ cdef extern from "whisper.h" nogil: whisper_encoder_begin_callback encoder_begin_callback void* encoder_begin_callback_user_data whisper_full_params whisper_full_default_params(whisper_sampling_strategy) - cdef whisper_context* whisper_init(char*) + cdef whisper_context* whisper_init_from_file(char*) cdef void whisper_free(whisper_context*) cdef int whisper_pcm_to_mel(whisper_context*, float*, int, int) cdef int whisper_set_mel(whisper_context*, float*, int, int) diff --git a/whispercpp.pyx b/whispercpp.pyx index fba2eff..005680d 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -16,7 +16,7 @@ cimport numpy as cnp cdef int SAMPLE_RATE = 16000 cdef char* TEST_FILE = 'test.wav' cdef char* DEFAULT_MODEL = 'tiny' -cdef char* LANGUAGE = b'fr' +cdef char* LANGUAGE = b'en' cdef int N_THREADS = os.cpu_count() MODELS = { @@ -33,8 +33,8 @@ def model_exists(model): def download_model(model): if model_exists(model): return - print(f'Downloading {model}...') + url = MODELS[model] r = requests.get(url, allow_redirects=True) os.makedirs(MODELS_DIR, exist_ok=True) @@ -85,11 +85,11 @@ cdef class Whisper: cdef whisper_full_params params def __init__(self, model=DEFAULT_MODEL, pb=None): - model_fullname = f'ggml-{model}.bin'.encode('utf8') + model_fullname = f'ggml-{model}.bin' #.encode('utf8') download_model(model_fullname) model_path = Path(MODELS_DIR).joinpath(model_fullname) cdef bytes model_b = str(model_path).encode('utf8') - self.ctx = whisper_init(model_b) + self.ctx = whisper_init_from_file(model_b) self.params = default_params() whisper_print_system_info() From 5534cc590d2ba0d2c6be247c16dc72aead5193db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Mon, 6 Mar 2023 20:48:47 +0100 Subject: [PATCH 02/27] removed .encode('utf-8') --- whispercpp.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whispercpp.pyx b/whispercpp.pyx index 005680d..f46aec8 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -85,7 +85,7 @@ cdef class Whisper: cdef whisper_full_params params def __init__(self, model=DEFAULT_MODEL, pb=None): - model_fullname = f'ggml-{model}.bin' #.encode('utf8') + model_fullname = f'ggml-{model}.bin' download_model(model_fullname) model_path = Path(MODELS_DIR).joinpath(model_fullname) cdef bytes model_b = str(model_path).encode('utf8') From af52074614dcbb91aef99e9824d16b3ef4e879c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Mon, 6 Mar 2023 20:54:25 +0100 Subject: [PATCH 03/27] updated .gitignore --- .gitignore | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b6e4761..102069f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__/ # C extensions *.so +/local # Distribution / packaging .Python build/ diff --git a/setup.py b/setup.py index bca94e3..af53e5e 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ os.environ['CXXFLAGS'] = '-DGGML_USE_ACCELERATE -O3 -std=c++11' os.environ['LDFLAGS'] = '-framework Accelerate' else: - os.environ['CFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3 -std=gnu11' + os.environ['CFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3' os.environ['CXXFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3 -std=c++11' ext_modules = [ From a54b768080cc464e9c7ae55cd56621888c7722ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Mon, 6 Mar 2023 21:17:04 +0100 Subject: [PATCH 04/27] added more models --- .gitignore | 3 +++ whispercpp.pyx | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 102069f..408faf8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,10 @@ __pycache__/ # C extensions *.so +# Prroject specific /local +whispercpp.cpp + # Distribution / packaging .Python build/ diff --git a/whispercpp.pyx b/whispercpp.pyx index f46aec8..08b5c95 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -21,10 +21,15 @@ cdef int N_THREADS = os.cpu_count() MODELS = { 'ggml-tiny.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin', + 'ggml-tiny.en.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-tiny.en.bin', 'ggml-base.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-base.bin', + 'ggml-base.en.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin', 'ggml-small.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-small.bin', + 'ggml-small.en.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin', 'ggml-medium.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin', + 'ggml-medium.en.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-medium.en.bin', 'ggml-large.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-large.bin', + 'ggml-large-v1.bin': 'https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-large-v1.bin', } def model_exists(model): From 606f3573f29bb52c84eb05410e0634113767c172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Mon, 6 Mar 2023 22:04:38 +0100 Subject: [PATCH 05/27] readded -gnu11 --- setup.py | 2 +- whispercpp.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index af53e5e..bca94e3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ os.environ['CXXFLAGS'] = '-DGGML_USE_ACCELERATE -O3 -std=c++11' os.environ['LDFLAGS'] = '-framework Accelerate' else: - os.environ['CFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3' + os.environ['CFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3 -std=gnu11' os.environ['CXXFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3 -std=c++11' ext_modules = [ diff --git a/whispercpp.pyx b/whispercpp.pyx index 08b5c95..408b626 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -62,7 +62,7 @@ cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] load_audio(bytes file, int sr capture_stderr=True ) )[0] - except: + except FileNotFoundError: raise RuntimeError(f"File '{file}' not found") cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = ( From c76e433a2350237bc19e744412e9f01274825eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Mon, 6 Mar 2023 23:23:46 +0100 Subject: [PATCH 06/27] added optional language parameter to transcribe --- whispercpp.pyx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/whispercpp.pyx b/whispercpp.pyx index 408b626..5f1bd3b 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -12,11 +12,12 @@ print("Saving models to:", MODELS_DIR) cimport numpy as cnp +from cpython.mem cimport PyMem_Malloc, PyMem_Free cdef int SAMPLE_RATE = 16000 cdef char* TEST_FILE = 'test.wav' cdef char* DEFAULT_MODEL = 'tiny' -cdef char* LANGUAGE = b'en' +cdef char* LANGUAGE = NULL cdef int N_THREADS = os.cpu_count() MODELS = { @@ -101,12 +102,17 @@ cdef class Whisper: def __dealloc__(self): whisper_free(self.ctx) - def transcribe(self, filename=TEST_FILE): - print("Loading data..") + def transcribe(self, filename=TEST_FILE, language=None): + print("Transcribing...") cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = load_audio(filename) - - print("Transcribing..") - return whisper_full(self.ctx, self.params, &frames[0], len(frames)) + if language: + print("Language:", language) + LANGUAGE = language.encode('utf-8') + self.params.language = LANGUAGE + else: + self.params.language = NULL + transcript = whisper_full(self.ctx, self.params, &frames[0], len(frames)) + return transcript def extract_text(self, int res): print("Extracting text...") From 49e9c62cf557a754699c4420a89fd204a9eacf0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Mon, 6 Mar 2023 23:40:22 +0100 Subject: [PATCH 07/27] updated Readme --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index f6fe283..f5393a8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,22 @@ Python bindings for whisper.cpp =============================== +This project provides Python bindings for the whisper.cpp library, which is a C++ implementation of a speech-to-text engine. The bindings are implemented in Cython, a language that allows easy integration between Python and C/C++ code. +# Installation `pip install git+https://github.com/o4dev/whispercpp.py` +# Examples +Once the package is installed, you can use it to transcribe speech files. Here's an example: +```python +from whispercpp import Whisper + +w = Whisper('tiny') + +result = w.transcribe("myfile.mp3", language='en') +text = w.extract_text(result) +``` +This code creates a Whisper object using the 'tiny' model and transcribes the audio file "myfile.mp3" using English language. The resulting result object is a byte string that can be decoded into a text string using the extract_text method. +If you don't specify a language, Whisper will try to determine the language of the audio: ```python from whispercpp import Whisper @@ -14,3 +28,25 @@ text = w.extract_text(result) Note: default parameters might need to be tweaked. See Whispercpp.pyx. + +# Available Models +The following models are available for use with Whispercpp.py: +| Model | Disk | Mem | SHA | +|-----------|---------|-----------|------------------------------------------------------------------| +| tiny | 75 MB | ~390 MB | bd577a113a864445d4c299885e0cb97d4ba92b5f | +| tiny.en | 75 MB | ~390 MB | c78c86eb1a8faa21b369bcd33207cc90d64ae9df | +| base | 142 MB | ~500 MB | 465707469ff3a37a2b9b8d8f89f2f99de7299dac | +| base.en | 142 MB | ~500 MB | 137c40403d78fd54d454da0f9bd998f78703390c | +| small | 466 MB | ~1.0 GB | 55356645c2b361a969dfd0ef2c5a50d530afd8d5 | +| small.en | 466 MB | ~1.0 GB | db8a495a91d927739e50b3fc1cc4c6b8f6c2d022 | +| medium | 1.5 GB | ~2.6 GB | fd9727b6e1217c2f614f9b698455c4ffd82463b4 | +| medium.en | 1.5 GB | ~2.6 GB | 8c30f0e44ce9560643ebd10bbe50cd20eafd3723 | +| large-v1 | 2.9 GB | ~4.7 GB | b1caaf735c4cc1429223d5a74f0f4d0b9b59a299 | +| large | 2.9 GB | ~4.7 GB | 0f4c8e34f21cf1a914c59d8b3ce882345ad349d6 | + +To use a specific model with Whispercpp.py, specify the model name when creating a Whisper object: +```python +from whispercpp import Whisper + +w = Whisper('base.en') +``` \ No newline at end of file From d3ec8006ce2f600946c204125fa5c727eff26927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:00:57 +0100 Subject: [PATCH 08/27] added more input options to tweak parameters --- whispercpp.pyx | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/whispercpp.pyx b/whispercpp.pyx index 5f1bd3b..e7d986f 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -1,6 +1,8 @@ #!python # cython: language_level=3 + + import ffmpeg import numpy as np import requests @@ -36,6 +38,13 @@ MODELS = { def model_exists(model): return os.path.exists(Path(MODELS_DIR).joinpath(model)) +def sampling_strategy_from_string(strategy_string): + strategy_map = { + 'GREEDY': whisper_sampling_strategy.WHISPER_SAMPLING_BEAM_SEARCH, + 'BEAM_SEARCH': whisper_sampling_strategy.WHISPER_SAMPLING_BEAM_SEARCH + } + return strategy_map[strategy_string.upper()] + def download_model(model): if model_exists(model): return @@ -49,6 +58,7 @@ def download_model(model): cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] load_audio(bytes file, int sr = SAMPLE_RATE): + print("Sampling rate:", sr) try: out = ( ffmpeg.input(file, threads=0) @@ -74,9 +84,10 @@ cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] load_audio(bytes file, int sr return frames -cdef whisper_full_params default_params() nogil: +cdef whisper_full_params default_params(strategy='GREEDY'): + strategy_value = sampling_strategy_from_string(strategy) cdef whisper_full_params params = whisper_full_default_params( - whisper_sampling_strategy.WHISPER_SAMPLING_GREEDY + strategy_value ) params.print_realtime = True params.print_progress = True @@ -87,24 +98,46 @@ cdef whisper_full_params default_params() nogil: cdef class Whisper: + """ + This class provides an interface for speech recognition using the Whisper library. + + Parameters: + ----------- + model (str): Model to use for transcription. One of ['ggml-tiny', 'ggml-tiny.en', 'ggml-base', + 'ggml-base.en', 'ggml-small', 'ggml-small.en', 'ggml-medium', 'ggml-medium.en', 'ggml-large', + 'ggml-large-v1']. Defaults to 'ggml-base'. + **kwargs: optional + Additional arguments to override the default parameters for speech recognition. + + Attributes: + ----------- + ctx: whisper_context * + The pointer to the Whisper context used for speech recognition. + params: whisper_full_params + The parameters used for speech recognition. + """ cdef whisper_context * ctx cdef whisper_full_params params - def __init__(self, model=DEFAULT_MODEL, pb=None): + def __init__(self, model='tiny', **kwargs): model_fullname = f'ggml-{model}.bin' download_model(model_fullname) model_path = Path(MODELS_DIR).joinpath(model_fullname) cdef bytes model_b = str(model_path).encode('utf8') self.ctx = whisper_init_from_file(model_b) - self.params = default_params() + self.params = default_params(kwargs.get('strategy', 'GREEDY')) whisper_print_system_info() + # Override default params + self.params.print_progress = kwargs.get('print_progress', True) + self.params.print_realtime = kwargs.get('print_realtime', True) + def __dealloc__(self): whisper_free(self.ctx) def transcribe(self, filename=TEST_FILE, language=None): print("Transcribing...") - cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = load_audio(filename) + cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = load_audio(filename, SAMPLE_RATE) if language: print("Language:", language) LANGUAGE = language.encode('utf-8') From a92a74c0d22f58e95b872fb834d7d0a25016b8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:12:27 +0100 Subject: [PATCH 09/27] updated github actions --- .github/workflows/build_wheels.yml | 1 + whispercpp.pyx | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 2dcab10..c1bc79d 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -7,6 +7,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 - name: Checkout submodules diff --git a/whispercpp.pyx b/whispercpp.pyx index e7d986f..137db5e 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -1,8 +1,6 @@ #!python # cython: language_level=3 - - import ffmpeg import numpy as np import requests @@ -107,7 +105,10 @@ cdef class Whisper: 'ggml-base.en', 'ggml-small', 'ggml-small.en', 'ggml-medium', 'ggml-medium.en', 'ggml-large', 'ggml-large-v1']. Defaults to 'ggml-base'. **kwargs: optional - Additional arguments to override the default parameters for speech recognition. + Additional arguments to override the default parameters for speech recognition. Accepts the following arguments: + - strategy (str): Sampling strategy to use. Choose from 'GREEDY' or 'BEAM_SEARCH'. Default: 'GREEDY'. + - print_progress (bool): Whether to print progress messages during transcription. Default: True. + - print_realtime (bool): Whether to print transcription results in real time. Default: True. Attributes: ----------- From 51c5a96b1e85964b0e782e82c1dd015e77b6062a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:34:11 +0100 Subject: [PATCH 10/27] added clang setup --- .github/workflows/build_wheels.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index c1bc79d..f259bb4 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10"] steps: - uses: actions/checkout@v2 - name: Checkout submodules @@ -22,6 +22,12 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install cibuildwheel==1.6.4 + + - name: Set up Clang + uses: egor-tensin/setup-clang@v1 + with: + version: latest + platform: x64 - name: Install run: | From fdc07e626dcdc251677b77b2aec67838aeb8d49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:38:24 +0100 Subject: [PATCH 11/27] added clang setup to macos --- .github/workflows/build_wheels.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index f259bb4..48a0636 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9", "3.10"] + python-version: ["3.10"] steps: - uses: actions/checkout@v2 - name: Checkout submodules @@ -22,12 +22,6 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install cibuildwheel==1.6.4 - - - name: Set up Clang - uses: egor-tensin/setup-clang@v1 - with: - version: latest - platform: x64 - name: Install run: | @@ -37,6 +31,12 @@ jobs: fi shell: bash + - name: Macos clang + run: | + if [ "$RUNNER_OS" == "macOS" ]; then + sudo xcode-select -s /Applications/Xcode_12.5.app/Contents/Developer + fi + - name: Build wheel run: python -m cibuildwheel --output-dir dist/ env: From 4c86dc4170ba3ce1d443659eaf8dc6749fa68ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:44:15 +0100 Subject: [PATCH 12/27] Switching to Xcode_12.5 --- .github/workflows/build_wheels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 48a0636..cde379d 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -31,10 +31,11 @@ jobs: fi shell: bash - - name: Macos clang + - name: macOS clang run: | if [ "$RUNNER_OS" == "macOS" ]; then sudo xcode-select -s /Applications/Xcode_12.5.app/Contents/Developer + clang -v fi - name: Build wheel From 72aaa600cbb5e2df5ed088073612768930f6c7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:46:29 +0100 Subject: [PATCH 13/27] Switching to Xcode_12.4 --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index cde379d..bfcfd4c 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -34,7 +34,7 @@ jobs: - name: macOS clang run: | if [ "$RUNNER_OS" == "macOS" ]; then - sudo xcode-select -s /Applications/Xcode_12.5.app/Contents/Developer + sudo xcode-select -s /Applications/Xcode_12.4.app/Contents/Developer clang -v fi From e22966fb6ee404f7172ab3b7c2ba8071221cdf46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:51:58 +0100 Subject: [PATCH 14/27] pleaase mac --- .github/workflows/build_wheels.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index bfcfd4c..773dc69 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -8,6 +8,8 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] + xcode: [13.2] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Checkout submodules @@ -31,12 +33,9 @@ jobs: fi shell: bash - - name: macOS clang - run: | - if [ "$RUNNER_OS" == "macOS" ]; then - sudo xcode-select -s /Applications/Xcode_12.4.app/Contents/Developer - clang -v - fi + - name: Change Xcode version to support clang99 + if: matrix.os == 'macOS-latest' + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer - name: Build wheel run: python -m cibuildwheel --output-dir dist/ From ce27e5b5b7211510507b353954f5f016372722bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:54:31 +0100 Subject: [PATCH 15/27] pleaase mac --- .github/workflows/build_wheels.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 773dc69..f56392f 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -33,9 +33,14 @@ jobs: fi shell: bash - - name: Change Xcode version to support clang99 - if: matrix.os == 'macOS-latest' - run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer + - name: Install dependencies + if: runner.os == 'macOS' + env: + HOMEBREW_NO_AUTO_UPDATE: 1 + run: | + brew update + brew install gcc + export CC=gcc-11 CXX=g++-11 - name: Build wheel run: python -m cibuildwheel --output-dir dist/ From b8c2ea61858c4fc6bb32b4fae1cfc5d8de545ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:55:32 +0100 Subject: [PATCH 16/27] removed duplicated matrix os --- .github/workflows/build_wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index f56392f..37f4212 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -9,7 +9,6 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] xcode: [13.2] - runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Checkout submodules From 4116ae8b1d870a54b08dbe118588dd60672ffa46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 21:59:40 +0100 Subject: [PATCH 17/27] fixed yaml format --- .github/workflows/build_wheels.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 37f4212..f0b6324 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -3,12 +3,11 @@ run-name: ${{ github.actor }} is building wheels on: [push] jobs: build_wheels: - runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] - xcode: [13.2] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Checkout submodules @@ -32,14 +31,14 @@ jobs: fi shell: bash - - name: Install dependencies - if: runner.os == 'macOS' - env: - HOMEBREW_NO_AUTO_UPDATE: 1 - run: | - brew update - brew install gcc - export CC=gcc-11 CXX=g++-11 + - name: Install dependencies + if: runner.os == 'macOS' + env: + HOMEBREW_NO_AUTO_UPDATE: 1 + run: | + brew update + brew install gcc + export CC=gcc-11 CXX=g++-11 - name: Build wheel run: python -m cibuildwheel --output-dir dist/ From 3662356a4587e248e577a8f04116ed4db13ca27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 22:12:09 +0100 Subject: [PATCH 18/27] moving models to .cache inline with XDG specification --- whispercpp.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whispercpp.pyx b/whispercpp.pyx index 137db5e..43869ff 100644 --- a/whispercpp.pyx +++ b/whispercpp.pyx @@ -7,7 +7,7 @@ import requests import os from pathlib import Path -MODELS_DIR = str(Path('~/.ggml-models').expanduser()) +MODELS_DIR = str(Path('~/.cache/ggml-models').expanduser()) print("Saving models to:", MODELS_DIR) From 2dd4fc8e9c7c7995e9fbaf5e5b796150bd57621d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 22:15:54 +0100 Subject: [PATCH 19/27] testing xcode 13.2 --- .github/workflows/build_wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index f0b6324..1d3c40c 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -7,6 +7,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] + xcode: [13.2] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 From f7799841e7783d0a368ffd7b236dac599a63372b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Tue, 7 Mar 2023 22:24:08 +0100 Subject: [PATCH 20/27] disabling macos for now --- .github/workflows/build_wheels.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 1d3c40c..ab497df 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,7 +5,8 @@ jobs: build_wheels: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, windows-latest] + # os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] xcode: [13.2] runs-on: ${{ matrix.os }} @@ -36,10 +37,11 @@ jobs: if: runner.os == 'macOS' env: HOMEBREW_NO_AUTO_UPDATE: 1 + CC: gcc-11 + CXX: g++-11 run: | brew update brew install gcc - export CC=gcc-11 CXX=g++-11 - name: Build wheel run: python -m cibuildwheel --output-dir dist/ From 6eb83dfaa2cb6c0971bccc491052f4a4f9dc4b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Wed, 8 Mar 2023 16:22:47 +0100 Subject: [PATCH 21/27] removing windows build agent for now --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index ab497df..8a35fce 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,7 +5,7 @@ jobs: build_wheels: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] # os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] xcode: [13.2] From 7115beb7b1116cb4de88b5cbb7a9ee118a715bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Wed, 8 Mar 2023 16:54:46 +0100 Subject: [PATCH 22/27] Specifying compiler --- .github/workflows/build_wheels.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 8a35fce..179a101 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,10 +5,16 @@ jobs: build_wheels: strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, windows-2022] # os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] xcode: [13.2] + compiler: + - llvm + - gcc + include: + - os: "windows-2022" + compiler: "msvc" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -33,16 +39,6 @@ jobs: fi shell: bash - - name: Install dependencies - if: runner.os == 'macOS' - env: - HOMEBREW_NO_AUTO_UPDATE: 1 - CC: gcc-11 - CXX: g++-11 - run: | - brew update - brew install gcc - - name: Build wheel run: python -m cibuildwheel --output-dir dist/ env: From e3303b51311a69bf4dc7ad0f92766619bab4215d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Wed, 8 Mar 2023 17:00:35 +0100 Subject: [PATCH 23/27] removed llvm compiler --- .github/workflows/build_wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 179a101..162fbca 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -10,7 +10,6 @@ jobs: python-version: ["3.10"] xcode: [13.2] compiler: - - llvm - gcc include: - os: "windows-2022" From 89825034460457d5f150b8860ea1e10f4f5018ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Wed, 8 Mar 2023 17:08:14 +0100 Subject: [PATCH 24/27] updated actions --- .github/workflows/build_wheels.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 162fbca..aca78cc 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -8,12 +8,7 @@ jobs: os: [ubuntu-latest, windows-2022] # os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] - xcode: [13.2] - compiler: - - gcc - include: - - os: "windows-2022" - compiler: "msvc" + #xcode: [13.2] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -38,6 +33,12 @@ jobs: fi shell: bash + - name: Install dependencies + if: runner.os == 'windows' + run: | + Invoke-WebRequest -Uri https://aka.ms/vs/16/release/vs_buildtools.exe -OutFile vs_buildtools.exe + ./vs_buildtools.exe --quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.140 --includeRecommended + - name: Build wheel run: python -m cibuildwheel --output-dir dist/ env: From e0f763af1f11df09f5e3ac07c3b02f196f7e8d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Wed, 8 Mar 2023 17:16:49 +0100 Subject: [PATCH 25/27] updated actions --- .github/workflows/build_wheels.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index aca78cc..94ea077 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,7 +5,7 @@ jobs: build_wheels: strategy: matrix: - os: [ubuntu-latest, windows-2022] + os: [ubuntu-latest, windows-latest] # os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10"] #xcode: [13.2] @@ -33,11 +33,13 @@ jobs: fi shell: bash - - name: Install dependencies + - name: Install MSBuild if: runner.os == 'windows' + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Set up C++ environment run: | - Invoke-WebRequest -Uri https://aka.ms/vs/16/release/vs_buildtools.exe -OutFile vs_buildtools.exe - ./vs_buildtools.exe --quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.140 --includeRecommended + "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 - name: Build wheel run: python -m cibuildwheel --output-dir dist/ From 37d5fb803a4f1a0db38d0a26f0eb18074212bace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Wed, 8 Mar 2023 17:19:38 +0100 Subject: [PATCH 26/27] updated actions --- .github/workflows/build_wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 94ea077..c88831c 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -38,6 +38,7 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Set up C++ environment + if: runner.os == 'windows' run: | "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 From 5e5408ab47965cc49db9b20f204262236880fcc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mico=20B=C3=B8je?= Date: Wed, 8 Mar 2023 17:22:06 +0100 Subject: [PATCH 27/27] updated actions --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index c88831c..d3a2543 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -40,7 +40,7 @@ jobs: - name: Set up C++ environment if: runner.os == 'windows' run: | - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 + "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86 - name: Build wheel run: python -m cibuildwheel --output-dir dist/