ggerganov commited on
Commit
4abd756
·
1 Parent(s): da23cbe

wip : initial WASM port

Browse files

Works but it is very slow because no SIMD is used.
For example, jfk.wav is processed in ~23 seconds using "tiny.en" model

CMakeLists.txt CHANGED
@@ -7,12 +7,28 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
7
 
8
  if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
9
  set(WHISPER_STANDALONE ON)
 
 
10
  else()
11
  set(WHISPER_STANDALONE OFF)
12
  endif()
13
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # options
15
 
 
 
16
  option(WHISPER_ALL_WARNINGS "whisper: enable all compiler warnings" ON)
17
  option(WHISPER_ALL_WARNINGS_3RD_PARTY "whisper: enable all compiler warnings in 3rd party libs" OFF)
18
 
@@ -20,7 +36,8 @@ option(WHISPER_SANITIZE_THREAD "whisper: enable thread sanitizer" OFF
20
  option(WHISPER_SANITIZE_ADDRESS "whisper: enable address sanitizer" OFF)
21
  option(WHISPER_SANITIZE_UNDEFINED "whisper: enable undefined sanitizer" OFF)
22
 
23
- option(WHISPER_BUILD_TESTS "whisper: build tests" ${WHISPER_STANDALONE})
 
24
 
25
  option(WHISPER_SUPPORT_SDL2 "whisper: support for libSDL2" OFF)
26
 
@@ -69,16 +86,6 @@ if (APPLE AND NOT WHISPER_NO_ACCELERATE)
69
  endif()
70
  endif()
71
 
72
- if (WHISPER_SUPPORT_SDL2)
73
- # SDL2
74
- find_package(SDL2 REQUIRED)
75
-
76
- string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
77
-
78
- message(STATUS "SDL2_INCLUDE_DIRS = ${SDL2_INCLUDE_DIRS}")
79
- message(STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}")
80
- endif()
81
-
82
  # compiler flags
83
 
84
  if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@@ -120,6 +127,11 @@ else()
120
  endif()
121
  endif()
122
 
 
 
 
 
 
123
  # whisper - this is the main library of the project
124
 
125
  set(TARGET whisper)
@@ -154,24 +166,46 @@ install(TARGETS ${TARGET}
154
  ARCHIVE DESTINATION lib/static
155
  )
156
 
 
 
 
 
157
  # programs, examples and tests
158
 
159
  if (WHISPER_STANDALONE)
160
- # main
161
- set(TARGET main)
162
- add_executable(${TARGET} main.cpp)
163
- target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})
164
-
165
- if (WHISPER_SUPPORT_SDL2)
166
- # stream
167
- set(TARGET stream)
168
- add_executable(${TARGET} stream.cpp)
169
- target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
170
- target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
171
- endif ()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  if (WHISPER_BUILD_TESTS)
174
  enable_testing()
175
  add_subdirectory(tests)
176
  endif ()
 
 
 
 
177
  endif ()
 
7
 
8
  if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
9
  set(WHISPER_STANDALONE ON)
10
+ include(cmake/GitVars.cmake)
11
+ include(cmake/BuildTypes.cmake)
12
  else()
13
  set(WHISPER_STANDALONE OFF)
14
  endif()
15
 
16
+ if (EMSCRIPTEN)
17
+ set(BUILD_SHARED_LIBS_DEFAULT OFF)
18
+
19
+ option(WHISPER_WASM_SINGLE_FILE "whisper: embed WASM inside the generated whisper.js" ON)
20
+ else()
21
+ if (MINGW)
22
+ set(BUILD_SHARED_LIBS_DEFAULT OFF)
23
+ else()
24
+ set(BUILD_SHARED_LIBS_DEFAULT ON)
25
+ endif()
26
+ endif()
27
+
28
  # options
29
 
30
+ option(BUILD_SHARED_LIBS "whisper: build shared libs" ${BUILD_SHARED_LIBS_DEFAULT})
31
+
32
  option(WHISPER_ALL_WARNINGS "whisper: enable all compiler warnings" ON)
33
  option(WHISPER_ALL_WARNINGS_3RD_PARTY "whisper: enable all compiler warnings in 3rd party libs" OFF)
34
 
 
36
  option(WHISPER_SANITIZE_ADDRESS "whisper: enable address sanitizer" OFF)
37
  option(WHISPER_SANITIZE_UNDEFINED "whisper: enable undefined sanitizer" OFF)
38
 
39
+ option(WHISPER_BUILD_TESTS "whisper: build tests" ${WHISPER_STANDALONE})
40
+ option(WHISPER_BUILD_EXAMPLES "whisper: build examples" ${WHISPER_STANDALONE})
41
 
42
  option(WHISPER_SUPPORT_SDL2 "whisper: support for libSDL2" OFF)
43
 
 
86
  endif()
87
  endif()
88
 
 
 
 
 
 
 
 
 
 
 
89
  # compiler flags
90
 
91
  if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
 
127
  endif()
128
  endif()
129
 
130
+ if (EMSCRIPTEN)
131
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -msimd128")
132
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
133
+ endif()
134
+
135
  # whisper - this is the main library of the project
136
 
137
  set(TARGET whisper)
 
166
  ARCHIVE DESTINATION lib/static
167
  )
168
 
169
+ # bindings
170
+
171
+ add_subdirectory(bindings)
172
+
173
  # programs, examples and tests
174
 
175
  if (WHISPER_STANDALONE)
176
+ if (NOT EMSCRIPTEN)
177
+ # TODO: move to examples
178
+ # main
179
+ set(TARGET main)
180
+ add_executable(${TARGET} main.cpp)
181
+ target_link_libraries(${TARGET} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})
182
+
183
+ # TODO: move to examples
184
+ if (WHISPER_SUPPORT_SDL2)
185
+ if (WHISPER_SUPPORT_SDL2)
186
+ # SDL2
187
+ find_package(SDL2 REQUIRED)
188
+
189
+ string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
190
+
191
+ message(STATUS "SDL2_INCLUDE_DIRS = ${SDL2_INCLUDE_DIRS}")
192
+ message(STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}")
193
+ endif()
194
+
195
+ # stream
196
+ set(TARGET stream)
197
+ add_executable(${TARGET} stream.cpp)
198
+ target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
199
+ target_link_libraries(${TARGET} PRIVATE whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
200
+ endif ()
201
+ endif()
202
 
203
  if (WHISPER_BUILD_TESTS)
204
  enable_testing()
205
  add_subdirectory(tests)
206
  endif ()
207
+
208
+ if (WHISPER_BUILD_EXAMPLES)
209
+ add_subdirectory(examples)
210
+ endif()
211
  endif ()
bindings/CMakeLists.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ if (EMSCRIPTEN)
2
+ add_subdirectory(javascript)
3
+ endif()
bindings/javascript/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ publish.log
bindings/javascript/CMakeLists.txt ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ set(TARGET libwhisper)
2
+
3
+ add_executable(${TARGET}
4
+ emscripten.cpp
5
+ )
6
+
7
+ target_link_libraries(${TARGET} PRIVATE
8
+ whisper
9
+ )
10
+
11
+ unset(EXTRA_FLAGS)
12
+ if (WHISPER_WASM_SINGLE_FILE)
13
+ set(EXTRA_FLAGS "-s SINGLE_FILE=1")
14
+ message(STATUS "Embedding WASM inside whisper.js")
15
+
16
+ add_custom_command(
17
+ TARGET libwhisper POST_BUILD
18
+ COMMAND ${CMAKE_COMMAND} -E copy
19
+ ${CMAKE_BINARY_DIR}/bin/libwhisper.js
20
+ ${CMAKE_CURRENT_SOURCE_DIR}/whisper.js
21
+ )
22
+ endif()
23
+
24
+ set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
25
+ --bind \
26
+ -s MODULARIZE=1 \
27
+ -s ASSERTIONS=1 \
28
+ -s USE_PTHREADS=1 \
29
+ -s PTHREAD_POOL_SIZE=8 \
30
+ -s TOTAL_MEMORY=536870912 \
31
+ -s FORCE_FILESYSTEM=1 \
32
+ -s EXPORT_NAME=\"'whisper_factory'\" \
33
+ ${EXTRA_FLAGS} \
34
+ ")
bindings/javascript/emscripten.cpp ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "whisper.h"
2
+
3
+ #include <emscripten.h>
4
+ #include <emscripten/bind.h>
5
+
6
+ #include <vector>
7
+
8
+ std::vector<struct whisper_context *> g_contexts(4, nullptr);
9
+
10
+ EMSCRIPTEN_BINDINGS(whisper) {
11
+ emscripten::function("init", emscripten::optional_override([](const std::string & path_model) {
12
+ for (size_t i = 0; i < g_contexts.size(); ++i) {
13
+ if (g_contexts[i] == nullptr) {
14
+ g_contexts[i] = whisper_init(path_model.c_str());
15
+ return i + 1;
16
+ }
17
+ }
18
+
19
+ return (size_t) 0;
20
+ }));
21
+
22
+ emscripten::function("free", emscripten::optional_override([](size_t index) {
23
+ --index;
24
+
25
+ if (index < g_contexts.size()) {
26
+ whisper_free(g_contexts[index]);
27
+ g_contexts[index] = nullptr;
28
+ }
29
+ }));
30
+
31
+ emscripten::function("full_default", emscripten::optional_override([](size_t index, const emscripten::val & audio) {
32
+ --index;
33
+
34
+ if (index >= g_contexts.size()) {
35
+ return -1;
36
+ }
37
+
38
+ if (g_contexts[index] == nullptr) {
39
+ return -2;
40
+ }
41
+
42
+ struct whisper_full_params params = whisper_full_default_params(whisper_sampling_strategy::WHISPER_SAMPLING_GREEDY);
43
+
44
+ params.print_realtime = true;
45
+ params.print_progress = false;
46
+ params.print_timestamps = true;
47
+ params.print_special_tokens = false;
48
+ params.translate = false;
49
+ params.language = "en";
50
+ params.n_threads = 4;
51
+ params.offset_ms = 0;
52
+
53
+ std::vector<float> pcmf32;
54
+ const int n = audio["length"].as<int>();
55
+
56
+ emscripten::val heap = emscripten::val::module_property("HEAPU8");
57
+ emscripten::val memory = heap["buffer"];
58
+
59
+ pcmf32.resize(n);
60
+
61
+ emscripten::val memoryView = audio["constructor"].new_(memory, reinterpret_cast<uintptr_t>(pcmf32.data()), n);
62
+ memoryView.call<void>("set", audio);
63
+
64
+ int ret = whisper_full(g_contexts[index], params, pcmf32.data(), pcmf32.size());
65
+
66
+ whisper_print_timings(g_contexts[index]);
67
+
68
+ return ret;
69
+ }));
70
+ }
bindings/javascript/whisper.js ADDED
The diff for this file is too large to render. See raw diff
 
cmake/BuildTypes.cmake ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Add new build types
2
+
3
+ # ReleaseGG - Release with enabled asserts
4
+
5
+ SET(CMAKE_CXX_FLAGS_RELEASEGG
6
+ "-O3"
7
+ CACHE STRING "Flags used by the c++ compiler during release builds with enabled asserts."
8
+ FORCE )
9
+ SET(CMAKE_C_FLAGS_RELEASEGG
10
+ "-O3"
11
+ CACHE STRING "Flags used by the compiler during release builds with enabled asserts."
12
+ FORCE )
13
+ SET(CMAKE_EXE_LINKER_FLAGS_RELEASEGG
14
+ ""
15
+ CACHE STRING "Flags used for linking binaries during release builds with enabled asserts."
16
+ FORCE )
17
+ SET(CMAKE_SHARED_LINKER_FLAGS_RELEASEGG
18
+ ""
19
+ CACHE STRING "Flags used by the shared libraries linker during release builds with enabled asserts."
20
+ FORCE )
21
+ MARK_AS_ADVANCED(
22
+ CMAKE_CXX_FLAGS_RELEASEGG
23
+ CMAKE_C_FLAGS_RELEASEGG
24
+ CMAKE_EXE_LINKER_FLAGS_RELEASEGG
25
+ CMAKE_SHARED_LINKER_FLAGS_RELEASEGG )
26
+
27
+ # RelWithDebInfoGG - RelWithDebInfo with enabled asserts
28
+
29
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFOGG
30
+ "-O2 -g"
31
+ CACHE STRING "Flags used by the c++ compiler during release builds with debug symbols and enabled asserts."
32
+ FORCE )
33
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFOGG
34
+ "-O2 -g"
35
+ CACHE STRING "Flags used by the compiler during release builds with debug symbols and enabled asserts."
36
+ FORCE )
37
+ SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFOGG
38
+ ""
39
+ CACHE STRING "Flags used for linking binaries during release builds with debug symbols and enabled asserts."
40
+ FORCE )
41
+ SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFOGG
42
+ ""
43
+ CACHE STRING "Flags used by the shared libraries linker during release builds with debug symbols and enabled asserts."
44
+ FORCE )
45
+ MARK_AS_ADVANCED(
46
+ CMAKE_CXX_FLAGS_RELWITHDEBINFOGG
47
+ CMAKE_C_FLAGS_RELWITHDEBINFOGG
48
+ CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFOGG
49
+ CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFOGG )
50
+
51
+ if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
52
+ set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
53
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "ReleaseGG" "RelWithDebInfoGG")
54
+ endif()
cmake/GitVars.cmake ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ find_package(Git)
2
+
3
+ # the commit's SHA1
4
+ execute_process(COMMAND
5
+ "${GIT_EXECUTABLE}" describe --match=NeVeRmAtCh --always --abbrev=8
6
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
7
+ OUTPUT_VARIABLE GIT_SHA1
8
+ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
9
+
10
+ # the date of the commit
11
+ execute_process(COMMAND
12
+ "${GIT_EXECUTABLE}" log -1 --format=%ad --date=local
13
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
14
+ OUTPUT_VARIABLE GIT_DATE
15
+ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
16
+
17
+ # the subject of the commit
18
+ execute_process(COMMAND
19
+ "${GIT_EXECUTABLE}" log -1 --format=%s
20
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
21
+ OUTPUT_VARIABLE GIT_COMMIT_SUBJECT
22
+ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
examples/CMakeLists.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # dependencies
2
+
3
+ find_package(Threads REQUIRED)
4
+
5
+ # third-party
6
+
7
+ #add_subdirectory(third-party)
8
+
9
+ # examples
10
+
11
+ if (EMSCRIPTEN)
12
+ add_subdirectory(whisper.wasm)
13
+ else()
14
+ endif()
examples/whisper.wasm/CMakeLists.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ set(TARGET whisper.wasm)
2
+
3
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index-tmpl.html ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/index.html @ONLY)
4
+ configure_file(${CMAKE_SOURCE_DIR}/bindings/javascript/whisper.js ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/whisper.js COPYONLY)
examples/whisper.wasm/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # whisper.wasm
2
+
3
+ Live demo: https://whisper.ggerganov.com
examples/whisper.wasm/index-tmpl.html ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en-us">
3
+ <head>
4
+ <title>whisper.cpp : WASM example</title>
5
+ </head>
6
+ <body>
7
+ <div id="main-container">
8
+ Minimal <b>whisper.cpp</b> example using Javascript bindings
9
+
10
+ <br><br>
11
+
12
+ Model:
13
+ <input type="file" id="file" name="file" onchange="loadFile(event, 'ggml.bin')" />
14
+ <br><br>
15
+
16
+ WAV:
17
+ <input type="file" id="file" name="file" onchange="loadAudio(event)" />
18
+ <br><br>
19
+
20
+ <button onclick="onTranscribe();">Transcribe</button>
21
+
22
+ <br><br>
23
+
24
+ <div class="cell-version">
25
+ <span>
26
+ |
27
+ Build time: <span class="nav-link">@GIT_DATE@</span> |
28
+ Commit hash: <a class="nav-link" href="https://github.com/ggerganov/whisper.cpp/commit/@GIT_SHA1@">@GIT_SHA1@</a> |
29
+ Commit subject: <span class="nav-link">@GIT_COMMIT_SUBJECT@</span> |
30
+ <a class="nav-link" href="https://github.com/ggerganov/whisper.cpp/tree/master/examples/whisper.wasm">Source Code</a> |
31
+ </span>
32
+ </div>
33
+ </div>
34
+
35
+ <script type="text/javascript" src="whisper.js"></script>
36
+ <script type='text/javascript'>
37
+ window.AudioContext = window.AudioContext || window.webkitAudioContext;
38
+ window.OfflineAudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext;
39
+
40
+ // web audio context
41
+ var context = null;
42
+
43
+ // audio data
44
+ var audio = null;
45
+
46
+ // the whisper module instance
47
+ var whisper = null;
48
+ var instance = null;
49
+
50
+ // instantiate the whisper instance
51
+ // whisper_factory comes from the whisper.js module
52
+ whisper_factory().then(function(obj) {
53
+ whisper = obj;
54
+ });
55
+
56
+ // helper function
57
+ function convertTypedArray(src, type) {
58
+ var buffer = new ArrayBuffer(src.byteLength);
59
+ var baseView = new src.constructor(buffer).set(src);
60
+ return new type(buffer);
61
+ }
62
+
63
+ // initialize whisper
64
+ function init() {
65
+ if (!instance) {
66
+ instance = whisper.init('ggml.bin');
67
+ if (instance) {
68
+ console.log('whisper instance initialized');
69
+ }
70
+ }
71
+
72
+ if (!instance) {
73
+ console.log('whisper instance initialization failed');
74
+ return;
75
+ }
76
+
77
+ if (instance) {
78
+ var ret = whisper.full_default(instance, audio);
79
+ if (ret) {
80
+ console.log('whisper full_default returned: ' + ret);
81
+ }
82
+ }
83
+ }
84
+
85
+ function loadFile(event, fname) {
86
+ var file = event.target.files[0] || null;
87
+ if (file == null) {
88
+ return;
89
+ }
90
+
91
+ console.log(
92
+ "<p>File information: <strong>" + file.name +
93
+ "</strong> type: <strong>" + file.type +
94
+ "</strong> size: <strong>" + file.size +
95
+ "</strong> bytes</p>"
96
+ );
97
+
98
+ var reader = new FileReader();
99
+ reader.onload = function(event) {
100
+ var buf = new Uint8Array(reader.result);
101
+
102
+ // write to WASM file using whisper.FS_createDataFile
103
+ whisper.FS_createDataFile("/", fname, buf, true, true);
104
+ }
105
+ reader.readAsArrayBuffer(file);
106
+ }
107
+
108
+ function loadAudio(event) {
109
+ if (!context) {
110
+ context = new AudioContext({sampleRate: 16000});
111
+ }
112
+
113
+ var file = event.target.files[0] || null;
114
+ if (file == null) {
115
+ return;
116
+ }
117
+
118
+ console.log(
119
+ "<p>Audio information: <strong>" + file.name +
120
+ "</strong> type: <strong>" + file.type +
121
+ "</strong> size: <strong>" + file.size +
122
+ "</strong> bytes</p>"
123
+ );
124
+
125
+ var reader = new FileReader();
126
+ reader.onload = function(event) {
127
+ var buf = new Uint8Array(reader.result);
128
+
129
+ context.decodeAudioData(buf.buffer, function(audioBuffer) {
130
+ var offlineContext = new OfflineAudioContext(audioBuffer.numberOfChannels, audioBuffer.length, audioBuffer.sampleRate);
131
+ var source = offlineContext.createBufferSource();
132
+ source.buffer = audioBuffer;
133
+ source.connect(offlineContext.destination);
134
+ source.start(0);
135
+
136
+ offlineContext.startRendering().then(function(renderedBuffer) {
137
+ audio = renderedBuffer.getChannelData(0);
138
+ //var audio16 = convertTypedArray(data, Int16Array);
139
+ });
140
+ });
141
+ }
142
+ reader.readAsArrayBuffer(file);
143
+ }
144
+ //
145
+ // Transcribe
146
+ //
147
+
148
+ function onTranscribe() {
149
+ init();
150
+ }
151
+ </script>
152
+ </body>
153
+ </html>
ggml.c CHANGED
@@ -7358,7 +7358,7 @@ enum ggml_opt_result ggml_opt_adam(
7358
 
7359
  {
7360
  const int64_t t_end_cpu = ggml_cycles();
7361
- GGML_PRINT_DEBUG("time iter: %5.3f s\n", (t_end_cpu - t_start_cpu)/CLOCKS_PER_SEC);
7362
  UNUSED(t_end_cpu);
7363
 
7364
  const int64_t t_end_wall = ggml_time_us();
 
7358
 
7359
  {
7360
  const int64_t t_end_cpu = ggml_cycles();
7361
+ GGML_PRINT_DEBUG("time iter: %5.3f s\n", ((float)(t_end_cpu - t_start_cpu))/CLOCKS_PER_SEC);
7362
  UNUSED(t_end_cpu);
7363
 
7364
  const int64_t t_end_wall = ggml_time_us();
tests/CMakeLists.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  set(TEST_TARGET test-main-tiny)
2
  add_test(NAME ${TEST_TARGET}
3
  COMMAND $<TARGET_FILE:main>
 
1
+ if (EMSCRIPTEN)
2
+ return()
3
+ endif()
4
+
5
  set(TEST_TARGET test-main-tiny)
6
  add_test(NAME ${TEST_TARGET}
7
  COMMAND $<TARGET_FILE:main>