Skip to content

Commit cc9d098

Browse files
Merge pull request #94 from AIWintermuteAI/updating-to-fix-CI
Fix the CI builds
2 parents 81cb0e9 + b078600 commit cc9d098

File tree

13 files changed

+53
-26
lines changed

13 files changed

+53
-26
lines changed

.github/workflows/ci.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches:
88
- develop
99
schedule:
10-
- cron: '00 12 * * 1' # Monday 12 PM UTC
10+
- cron: '00 12 1 * *' # First day of each month 12 PM UTC
1111
concurrency:
1212
group: ci-${{ github.head_ref || github.run_id }}
1313
cancel-in-progress: true
@@ -23,9 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
os: [ubuntu-latest, macos-latest, windows-latest]
27-
exclude:
28-
- os: 'windows-latest'
26+
os: [ubuntu-latest, macos-latest]
2927
name: Integration tests (${{ matrix.os }})
3028
runs-on: ${{ matrix.os }}
3129
timeout-minutes: 90
@@ -37,7 +35,7 @@ jobs:
3735
- name: Setup CI
3836
uses: ./.github/actions/setup-repo
3937
with:
40-
python-version: '3.8' # sync with default version in WORKSPACE.
38+
python-version: '3.11.8' # sync with default version in WORKSPACE.
4139
- name: Install development dependencies and bindings
4240
run: |
4341
bazel run pypi_update

.github/workflows/submodule-update.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ name: Submodule Updates
77
on:
88
workflow_dispatch:
99
schedule:
10-
- cron: '00 12 * * 1' # Monday 12 PM UTC
11-
10+
- cron: '00 12 1 * *' # First day of each month 12 PM UTC
11+
1212
###############
1313
# Set the Job #
1414
###############

.github/workflows/wheels.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
pull_request:
88
branches:
99
- develop
10+
schedule:
11+
- cron: '00 12 1 * *' # First day of each month 12 PM UTC
1012
concurrency:
1113
group: wheels-${{ github.head_ref || github.run_id }}
1214
cancel-in-progress: true
@@ -51,10 +53,11 @@ jobs:
5153
strategy:
5254
fail-fast: false
5355
matrix:
54-
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
55-
python-version: ['3.10', '3.11']
56+
os: ['ubuntu-latest', 'macos-latest']
57+
python-version: ['3.10', '3.11.8']
5658
exclude:
57-
- os: 'windows-latest'
59+
- os: 'macos-latest'
60+
python-version: '3.10'
5861
steps:
5962
- name: Checkout
6063
uses: actions/checkout@v4

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,4 @@ bun.lockb
136136
*.bin
137137

138138
src/whispercpp/__about__.py
139+
.vscode/settings.json

BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ py_wheel(
221221
homepage = "https://github.com/aarnphm/whispercpp",
222222
license = "Apache 2.0",
223223
platform = select({
224-
"//:aarch64-apple-darwin": "macosx_10_9_arm64",
224+
"//:aarch64-apple-darwin": "macosx_14_0_arm64",
225225
"//:aarch64-unknown-linux-gnu": "manylinux2014_aarch64",
226-
"//:x86_64-apple-darwin": "macosx_10_9_x86_64",
226+
"//:x86_64-apple-darwin": "macosx_14_0_x86_64",
227227
"//:x86_64-pc-windows-msvc": "win_amd64",
228228
"//:x86_64-unknown-linux-gnu": "manylinux2014_x86_64",
229229
}),

examples/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ py_test(
1616
"//src/whispercpp:whispercpp_lib",
1717
requirement("bazel-runfiles"),
1818
requirement("numpy"),
19-
requirement("pydub"),
2019
],
2120
)

examples/bindings/explore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def main(argv: list[str]) -> int:
3434
assert Path(path).exists()
3535
params = get_model().params.with_print_realtime(True).build()
3636
assert _model is not None
37-
_model.context.full(params, w.api.load_wav_file(Path(path).__fspath__()).mono)
37+
_model.context.full(params, w.api.load_wav_file_mono(Path(path).__fspath__()))
3838
return 0
3939

4040

requirements/pypi.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pydub==0.25.1
21
ruff
32
black
43
bazel-runfiles==0.19.0
@@ -10,4 +9,4 @@ pytest-xdist[psutil]
109
pytest-asyncio
1110
build
1211
virtualenv
13-
twine
12+
twine

rules/deps.bzl

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def internal_deps():
9696
# Override python rules defined under @com_github_bentoml_plugins
9797
http_archive(
9898
name = "rules_python",
99-
sha256 = "b0a45e1fdaade7ac4975a9dfa08a170b78e209ba717946f7d397a75dc8a9fda6",
100-
strip_prefix = "rules_python-4e3d01c9f6a6cda0fb34b7c2961d6b1ef5313218",
101-
url = "https://github.com/bazelbuild/rules_python/archive/4e3d01c9f6a6cda0fb34b7c2961d6b1ef5313218.tar.gz",
99+
sha256 = "3d6fe72f1a056b3462f02afba5049210acbaec131087fb19082fa6792198a9fa",
100+
strip_prefix = "rules_python-084b877c98b580839ceab2b071b02fc6768f3de6",
101+
url = "https://github.com/bazelbuild/rules_python/archive/084b877c98b580839ceab2b071b02fc6768f3de6.tar.gz",
102102
)

src/whispercpp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def transcribe_from_file(
221221
Transcribed text.
222222
"""
223223
return self.transcribe(
224-
api.load_wav_file(filename).mono, num_proc=num_proc, strict=strict
224+
api.load_wav_file_mono(filename), num_proc=num_proc, strict=strict
225225
)
226226

227227
def stream_transcribe(

src/whispercpp/api_cpp2py_export.cc

+24
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ WavFileWrapper WavFileWrapper::load_wav_file(const char *filename) {
99
return WavFileWrapper(&pcmf32, &pcmf32s);
1010
}
1111

12+
std::vector<std::vector<float>> load_wav_file_stereo(const char *filename) {
13+
std::vector<float> pcmf32;
14+
std::vector<std::vector<float>> pcmf32s;
15+
if (!::read_wav(filename, pcmf32, pcmf32s, true)) {
16+
throw std::runtime_error("Failed to load wav file");
17+
}
18+
return pcmf32s;
19+
}
20+
21+
std::vector<float> load_wav_file_mono(const char *filename) {
22+
std::vector<float> pcmf32;
23+
std::vector<std::vector<float>> pcmf32s;
24+
if (!::read_wav(filename, pcmf32, pcmf32s, false)) {
25+
throw std::runtime_error("Failed to load wav file");
26+
}
27+
return pcmf32;
28+
}
29+
1230
namespace py = pybind11;
1331
using namespace pybind11::literals;
1432

@@ -58,6 +76,12 @@ PYBIND11_MODULE(api_cpp2py_export, m) {
5876
whisper_sampling_strategy::WHISPER_SAMPLING_BEAM_SEARCH)
5977
.export_values();
6078

79+
m.def("load_wav_file_stereo", load_wav_file_stereo, "filename"_a,
80+
py::return_value_policy::reference);
81+
82+
m.def("load_wav_file_mono", load_wav_file_mono, "filename"_a,
83+
py::return_value_policy::reference);
84+
6185
m.def("load_wav_file", &WavFileWrapper::load_wav_file, "filename"_a,
6286
py::return_value_policy::reference);
6387

tests/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ py_test(
1919
"//src/whispercpp:whispercpp_lib",
2020
requirement("bazel-runfiles"),
2121
requirement("numpy"),
22-
requirement("pydub"),
2322
],
2423
)
2524

tests/export_test.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest as p
88

99
import whispercpp as w
10-
from pydub import AudioSegment as am
10+
import wave
1111

1212
if t.TYPE_CHECKING:
1313
import numpy as np
@@ -21,10 +21,14 @@
2121

2222
def preprocess(file: Path, sample_rate: int = 16000) -> NDArray[np.float32]:
2323

24-
sound = am.from_file(file, format='wav', frame_rate=sample_rate)
25-
sound = sound.set_frame_rate(sample_rate).get_array_of_samples()
24+
sound = wave.open(str(file), "rb")
25+
nchannels = sound.getnchannels()
26+
N = sound.getnframes()
27+
dstr = sound.readframes(N*nchannels)
28+
data = np.fromstring(dstr, np.int16)
29+
data = data.reshape(-1, nchannels)
2630

27-
return np.frombuffer(sound, np.int16).flatten().astype(np.float32) / 32768.0
31+
return data.flatten().astype(np.float32) / 32768.0
2832

2933
def test_invalid_models():
3034
with p.raises(RuntimeError):
@@ -73,7 +77,7 @@ def test_from_params_file(models: str):
7377
def test_load_wav_file():
7478
np.testing.assert_almost_equal(
7579
preprocess(JFK_WAV),
76-
w.api.load_wav_file(str(JFK_WAV.resolve())).mono,
80+
w.api.load_wav_file_mono(str(JFK_WAV.resolve())),
7781
)
7882

7983
def transcribe_strict():

0 commit comments

Comments
 (0)