Skip to content

Commit

Permalink
Updated whisper.cpp to 1.5.0 (#60)
Browse files Browse the repository at this point in the history
* Updated code and windows

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Update build_cpp.yml

* Updated Linux lib

* Disabled metal for now

* Updated mac, ios and android

* Update README.md

* Update test.yml

* Update test.yml

* Delete .github/workflows/activation.yml

* Reset tests

* Update test.yml
  • Loading branch information
Macoron committed Nov 19, 2023
1 parent a64d182 commit 75a5a53
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 36 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/activation.yml

This file was deleted.

22 changes: 16 additions & 6 deletions .github/workflows/build_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
whisper_cpp_repo_ref:
description: 'Tag, branch or commit'
required: true
default: 'v1.4.2'
default: 'v1.5.0'
jobs:
build-windows:
name: Build for Windows (x86_64)
Expand Down Expand Up @@ -61,14 +61,24 @@ jobs:
ref: ${{ github.event.inputs.whisper_cpp_repo_ref }}
path: whisper-cpp

- name: Dependencies
- name: Latest Cmake
run: |
apt-get update
apt-get install -y build-essential
apt-get install -y cmake
apt-get update \
&& apt-get install -y build-essential \
&& apt-get install -y wget \
&& rm -rf /var/lib/apt/lists/* \
&& wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& mkdir /opt/cmake-3.24.1 \
&& /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.24.1 \
&& rm /tmp/cmake-install.sh \
&& ln -s /opt/cmake-3.24.1/bin/* /usr/local/bin
- name: Change gcc and g++
run: apt-get install -y gcc-8 g++-8
run: |
apt-get update
apt-get install -y gcc-8 g++-8
- name: Run build script
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
matrix:
unityVersion:
- 2019.4.40f1
- 2020.3.48f1
- 2021.3.25f1
- 2022.2.19f1
steps:
- uses: actions/checkout@v3
- uses: game-ci/unity-test-runner@v2
Expand Down
Binary file modified Packages/com.whisper.unity/Plugins/Android/libwhisper.a
Binary file not shown.
Binary file modified Packages/com.whisper.unity/Plugins/Linux/libwhisper.so
Binary file not shown.
Binary file modified Packages/com.whisper.unity/Plugins/MacOS/libwhisper.dylib
Binary file not shown.
Binary file modified Packages/com.whisper.unity/Plugins/Windows/libwhisper.dll
Binary file not shown.
Binary file modified Packages/com.whisper.unity/Plugins/iOS/libwhisper.a
Binary file not shown.
24 changes: 20 additions & 4 deletions Packages/com.whisper.unity/Runtime/Native/WhisperNativeParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using whisper_context_ptr = System.IntPtr;
using whisper_state_ptr = System.IntPtr;
using whisper_token = System.Int32;
using System;

namespace Whisper.Native
{
Expand All @@ -19,11 +20,11 @@ public enum WhisperSamplingStrategy

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void whisper_new_segment_callback(whisper_context_ptr ctx, whisper_state_ptr state,
int n_new, System.IntPtr user_data);
int n_new, IntPtr user_data);

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void whisper_progress_callback(whisper_context_ptr ctx, whisper_state_ptr state,
int progress, System.IntPtr user_data);
int progress, IntPtr user_data);

/// <summary>
/// This is direct copy of C++ struct.
Expand Down Expand Up @@ -66,6 +67,7 @@ public unsafe struct WhisperNativeParams

[MarshalAs(UnmanagedType.U1)] public bool translate;
[MarshalAs(UnmanagedType.U1)] public bool no_context; // do not use past transcription (if any) as initial prompt for the decoder
[MarshalAs(UnmanagedType.U1)] bool no_timestamps; // do not generate timestamps
[MarshalAs(UnmanagedType.U1)] public bool single_segment; // force single segment output (useful for streaming)
[MarshalAs(UnmanagedType.U1)] public bool print_special; // print special tokens (e.g. <SOT>, <EOT>, <BEG>, etc.)
[MarshalAs(UnmanagedType.U1)] public bool print_progress; // print progress information
Expand All @@ -83,8 +85,12 @@ public unsafe struct WhisperNativeParams
// [EXPERIMENTAL] speed-up techniques
// note: these can significantly reduce the quality of the output
[MarshalAs(UnmanagedType.U1)] public bool speed_up; // speed-up the audio by 2x using Phase Vocoder
[MarshalAs(UnmanagedType.U1)] bool debug_mode; // enable debug_mode provides extra info (eg. Dump log_mel)
public int audio_ctx; // overwrite the audio context size (0 = use default)

// [EXPERIMENTAL] [TDRZ] tinydiarize
[MarshalAs(UnmanagedType.U1)] bool tdrz_enable; // enable tinydiarize speaker turn detection

// tokens to provide to the whisper decoder as initial prompt
// these are prepended to any existing text context from a previous call
public byte* initial_prompt;
Expand Down Expand Up @@ -129,18 +135,28 @@ struct beam_search_struct

// called for every newly generated text segment
public whisper_new_segment_callback new_segment_callback;
public System.IntPtr new_segment_callback_user_data;
public IntPtr new_segment_callback_user_data;

// called on each progress update
public whisper_progress_callback progress_callback;
public System.IntPtr progress_callback_user_data;
public IntPtr progress_callback_user_data;

// called each time before the encoder starts
void* encoder_begin_callback;
void* encoder_begin_callback_user_data;

// called each time before ggml computation starts
void* abort_callback;
void* abort_callback_user_data;

// called by each decoder to filter obtained logits
void* logits_filter_callback;
void* logits_filter_callback_user_data;


IntPtr grammar_rules;
UIntPtr n_grammar_rules;
UIntPtr i_start_rule;
float grammar_penalty;
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# whisper.unity
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![whisper.cpp](https://img.shields.io/badge/whisper.cpp-v1.4.2-green)](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.4.2)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![whisper.cpp](https://img.shields.io/badge/whisper.cpp-v1.5.0-green)](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.5.0)

[![Testing](https://github.com/Macoron/whisper.unity/actions/workflows/test.yml/badge.svg)](https://github.com/Macoron/whisper.unity/actions/workflows/test.yml)

Expand Down Expand Up @@ -51,7 +51,7 @@ This project comes with prebuild libraries of whisper.cpp for all supported plat

In case you want to build libraries on your machine:
1. Clone the original [whisper.cpp](https://github.com/ggerganov/whisper.cpp) repository
2. Checkout tag [v1.4.2](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.4.2). Other versions might not work with this Unity bindings.
2. Checkout tag [v1.5.0](https://github.com/ggerganov/whisper.cpp/tree/v1.5.0). Other versions might not work with this Unity bindings.
3. Open whisper.unity folder with command line
4. If you are using **Windows** write:
```bash
Expand Down
7 changes: 4 additions & 3 deletions build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ build_mac() {
clean_build
echo "Starting building for Mac..."

cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF \
-DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON -DWHISPER_NO_FMA=ON -DWHISPER_NO_F16C=ON ../
cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DWHISPER_METAL=OFF \
-DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON -DWHISPER_NO_FMA=ON -DWHISPER_NO_F16C=ON \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make

echo "Build for Mac complete!"
Expand All @@ -34,7 +35,7 @@ build_ios() {
echo "Starting building for ios..."

cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DWHISPER_METAL=OFF \
-DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_IOS_INSTALL_COMBINED=YES \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
Expand Down

0 comments on commit 75a5a53

Please sign in to comment.