Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
* origin/master:
  bench.py : add different large models (ggerganov#1655)
  wchess : update README.md
  release : v1.5.2
  wchess : update readme
  wchess : whisper assisted chess (ggerganov#1595)
  sync : ggml (Metal fixes, new ops, tests) (ggerganov#1633)
  cmake : target windows 8 or above for prefetchVirtualMemory in llama-talk (ggerganov#1617)
  cmake : Fix bug in httplib.h for mingw (ggerganov#1615)
  metal : fix `ggml_metal_log` vargs (ggerganov#1606)
  whisper.objc : disable timestamps for real-time transcription
  whisper : more debug messages + fix fallback logic
  metal : fix soft_max kernel src1 argument (ggerganov#1602)
  sync : ggml (new ops, new backend, etc) (ggerganov#1602)
  server : pass max-len argument to the server (ggerganov#1574)
  ios : Remove `#if arch(arm)` check for using Metal (ggerganov#1561)
  ggml : Fix 32-bit compiler warning (ggerganov#1575)
  ggml : re-enable blas for src0 != F32 (ggerganov#1583)
  • Loading branch information
bygreencn committed Dec 20, 2023
2 parents fe9a9c4 + 9286d3f commit b63ec23
Show file tree
Hide file tree
Showing 64 changed files with 11,178 additions and 1,596 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.5)

project(whisper.cpp VERSION 1.5.1)
project(whisper.cpp VERSION 1.5.2)

# Add path to modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
Expand Down
46 changes: 15 additions & 31 deletions Package.swift
Expand Up @@ -2,41 +2,22 @@

import PackageDescription

#if arch(arm) || arch(arm64)
let platforms: [SupportedPlatform]? = [
.macOS(.v12),
.iOS(.v14),
.watchOS(.v4),
.tvOS(.v14)
]
let exclude: [String] = []
let resources: [Resource] = [
.process("ggml-metal.metal")
]
let additionalSources: [String] = ["ggml-metal.m"]
let additionalSettings: [CSetting] = [
.unsafeFlags(["-fno-objc-arc"]),
.define("GGML_USE_METAL")
]
#else
let platforms: [SupportedPlatform]? = nil
let exclude: [String] = ["ggml-metal.metal"]
let resources: [Resource] = []
let additionalSources: [String] = []
let additionalSettings: [CSetting] = []
#endif

let package = Package(
name: "whisper",
platforms: platforms,
platforms: [
.macOS(.v12),
.iOS(.v14),
.watchOS(.v4),
.tvOS(.v14)
],
products: [
.library(name: "whisper", targets: ["whisper"]),
],
targets: [
.target(
name: "whisper",
path: ".",
exclude: exclude + [
exclude: [
"bindings",
"cmake",
"coreml",
Expand All @@ -55,19 +36,22 @@ let package = Package(
"whisper.cpp",
"ggml-alloc.c",
"ggml-backend.c",
"ggml-quants.c"
] + additionalSources,
resources: resources,
"ggml-quants.c",
"ggml-metal.m"
],
resources: [.process("ggml-metal.metal")],
publicHeadersPath: "spm-headers",
cSettings: [
.unsafeFlags(["-Wno-shorten-64-to-32", "-O3", "-DNDEBUG"]),
.define("GGML_USE_ACCELERATE")
.define("GGML_USE_ACCELERATE"),
.unsafeFlags(["-fno-objc-arc"]),
.define("GGML_USE_METAL")
// NOTE: NEW_LAPACK will required iOS version 16.4+
// We should consider add this in the future when we drop support for iOS 14
// (ref: ref: https://developer.apple.com/documentation/accelerate/1513264-cblas_sgemm?language=objc)
// .define("ACCELERATE_NEW_LAPACK"),
// .define("ACCELERATE_LAPACK_ILP64")
] + additionalSettings,
],
linkerSettings: [
.linkedFramework("Accelerate")
]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![npm](https://img.shields.io/npm/v/whisper.cpp.svg)](https://www.npmjs.com/package/whisper.cpp/)

Stable: [v1.5.1](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.5.1) / [Roadmap | F.A.Q.](https://github.com/ggerganov/whisper.cpp/discussions/126)
Stable: [v1.5.2](https://github.com/ggerganov/whisper.cpp/releases/tag/v1.5.2) / [Roadmap | F.A.Q.](https://github.com/ggerganov/whisper.cpp/discussions/126)

High-performance inference of [OpenAI's Whisper](https://github.com/openai/whisper) automatic speech recognition (ASR) model:

Expand Down Expand Up @@ -770,6 +770,7 @@ Some of the examples are even ported to run in the browser using WebAssembly. Ch
| [bench](examples/bench) | [bench.wasm](examples/bench.wasm) | Benchmark the performance of Whisper on your machine |
| [stream](examples/stream) | [stream.wasm](examples/stream.wasm) | Real-time transcription of raw microphone capture |
| [command](examples/command) | [command.wasm](examples/command.wasm) | Basic voice assistant example for receiving voice commands from the mic |
| [wchess](examples/wchess) | [wchess.wasm](examples/wchess) | Voice-controlled chess |
| [talk](examples/talk) | [talk.wasm](examples/talk.wasm) | Talk with a GPT-2 bot |
| [talk-llama](examples/talk-llama) | | Talk with a LLaMA bot |
| [whisper.objc](examples/whisper.objc) | | iOS mobile application using whisper.cpp |
Expand Down
2 changes: 1 addition & 1 deletion bindings/javascript/package.json
@@ -1,6 +1,6 @@
{
"name": "whisper.cpp",
"version": "1.5.1",
"version": "1.5.2",
"description": "Whisper speech recognition",
"main": "whisper.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion bindings/javascript/whisper.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Expand Up @@ -187,3 +187,5 @@ else()
#add_subdirectory(talk-llama)
#add_subdirectory(lsp)
endif()

add_subdirectory(wchess)
1 change: 1 addition & 0 deletions examples/helpers.js
Expand Up @@ -22,6 +22,7 @@ var printTextarea = (function() {
async function clearCache() {
if (confirm('Are you sure you want to clear the cache?\nAll the models will be downloaded again.')) {
indexedDB.deleteDatabase(dbName);
location.reload();
}
}

Expand Down
6 changes: 6 additions & 0 deletions examples/server/CMakeLists.txt
Expand Up @@ -4,3 +4,9 @@ add_executable(${TARGET} server.cpp httplib.h json.hpp)
include(DefaultTargetOptions)

target_link_libraries(${TARGET} PRIVATE common whisper ${CMAKE_THREAD_LIBS_INIT})

# Check if the compiler is MinGW
if(MINGW)
# Link the necessary libraries for SSL and Winsock
target_link_libraries(${TARGET} PRIVATE -lcrypt32 -lssl -lcrypto -lws2_32)
endif()
1 change: 1 addition & 0 deletions examples/server/server.cpp
Expand Up @@ -589,6 +589,7 @@ int main(int argc, char ** argv) {
wparams.duration_ms = params.duration_ms;

wparams.thold_pt = params.word_thold;
wparams.max_len = params.max_len == 0 ? 60 : params.max_len;
wparams.split_on_word = params.split_on_word;

wparams.speed_up = params.speed_up;
Expand Down
5 changes: 5 additions & 0 deletions examples/talk-llama/CMakeLists.txt
Expand Up @@ -18,6 +18,11 @@ if (WHISPER_SDL2)
../../ggml-quants.c
../../whisper.cpp)

if(WIN32)
# It requires Windows 8.1 or later for PrefetchVirtualMemory
target_compile_definitions(${TARGET} PRIVATE -D_WIN32_WINNT=0x0602)
endif()

target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS} ../../)
target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

Expand Down
9 changes: 9 additions & 0 deletions examples/wchess/CMakeLists.txt
@@ -0,0 +1,9 @@
set(CMAKE_CXX_STANDARD 11)

add_subdirectory(libwchess)

if (EMSCRIPTEN)
add_subdirectory(wchess.wasm)
else()
add_subdirectory(wchess.cmd)
endif()
45 changes: 45 additions & 0 deletions examples/wchess/README.md
@@ -0,0 +1,45 @@
# wchess

Voice-controlled chess using Whisper

Online demo: https://whisper.ggerganov.com/wchess/

https://github.com/ggerganov/whisper.cpp/assets/1991296/c2b2f03c-9684-49f3-8106-357d2d4e67fa

## Command-line tool

```bash
mkdir build && cd build
cmake -DWHISPER_SDL2=1 ..
make -j

./bin/wchess -m ../models/ggml-base.en.bin

Move: start

a b c d e f g h
r n b q k b n r 8
p p p p p p p p 7
. * . * . * . * 6
* . * . * . * . 5
. * . * . * . * 4
* . * . * . * . 3
P P P P P P P P 2
R N B Q K B N R 1

White's turn
[(l)isten/(p)ause/(q)uit]:
```
## TODO
- Fix bugs in the chess moves logic
- Improve web-browser audio capture - sometimes it does not record the voice properly
- Add support for more languages by making the generated grammar string multilingual
- Explore ways to improve the dynamic grammar to be narrower
PRs welcome!
## Thanks
- [chessboardjs](https://chessboardjs.com) for the neat chessboard JS library used in this demo
19 changes: 19 additions & 0 deletions examples/wchess/libwchess/CMakeLists.txt
@@ -0,0 +1,19 @@
add_library(wchess-core STATIC
WChess.cpp
WChess.h
Chessboard.cpp
Chessboard.h
)

target_link_libraries(wchess-core
PUBLIC
whisper
common
)

target_include_directories(wchess-core
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
)

# add_executable(test-chessboard test-chessboard.cpp Chessboard.cpp)

0 comments on commit b63ec23

Please sign in to comment.