Skip to content

Commit d987ed0

Browse files
committed
cont server [no ci]
1 parent 7155163 commit d987ed0

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ Some of the examples are even ported to run in the browser using WebAssembly. Ch
611611
| [whisper-bench](examples/bench) | [bench.wasm](examples/bench.wasm) | Benchmark the performance of Whisper on your machine |
612612
| [whisper-stream](examples/stream) | [stream.wasm](examples/stream.wasm) | Real-time transcription of raw microphone capture |
613613
| [whisper-command](examples/command) | [command.wasm](examples/command.wasm) | Basic voice assistant example for receiving voice commands from the mic |
614-
| [wchess](examples/wchess) | [wchess.wasm](examples/wchess) | Voice-controlled chess |
614+
| [whisper-server](examples/server) | | HTTP transcription server with OAI-like API |
615615
| [talk-llama](examples/talk-llama) | | Talk with a LLaMA bot |
616616
| [whisper.objc](examples/whisper.objc) | | iOS mobile application using whisper.cpp |
617617
| [whisper.swiftui](examples/whisper.swiftui) | | SwiftUI iOS / macOS application using whisper.cpp |
@@ -620,7 +620,7 @@ Some of the examples are even ported to run in the browser using WebAssembly. Ch
620620
| [generate-karaoke.sh](examples/generate-karaoke.sh) | | Helper script to easily [generate a karaoke video](https://youtu.be/uj7hVta4blM) of raw audio capture |
621621
| [livestream.sh](examples/livestream.sh) | | [Livestream audio transcription](https://github.com/ggerganov/whisper.cpp/issues/185) |
622622
| [yt-wsp.sh](examples/yt-wsp.sh) | | Download + transcribe and/or translate any VOD [(original)](https://gist.github.com/DaniruKun/96f763ec1a037cc92fe1a059b643b818) |
623-
| [server](examples/server) | | HTTP transcription server with OAI-like API |
623+
| [wchess](examples/wchess) | [wchess.wasm](examples/wchess) | Voice-controlled chess |
624624

625625
## [Discussions](https://github.com/ggerganov/whisper.cpp/discussions)
626626

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
add_executable(main ./deprecation-warning.cpp)
2-
target_compile_features(main PRIVATE cxx_std_11)
3-
42
add_executable(bench ./deprecation-warning.cpp)
5-
target_compile_features(bench PRIVATE cxx_std_11)
6-
73
add_executable(stream ./deprecation-warning.cpp)
8-
target_compile_features(stream PRIVATE cxx_std_11)
4+
add_executable(command ./deprecation-warning.cpp)

examples/deprecation-warning/deprecation-warning.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ int main(int argc, char** argv) {
1111
}
1212

1313
// Get only the program name from the full path
14-
auto pos = filename.find_last_of("/\\");
14+
size_t pos = filename.find_last_of("/\\");
1515
if (pos != std::string::npos) {
1616
filename = filename.substr(pos+1);
1717
}
1818

1919
// Append "whisper-" to the beginning of filename to get the replacemnt filename
20-
auto replacement_filename = "whisper-" + filename;
20+
std::string replacement_filename = "whisper-" + filename;
2121

2222
// The exception is if the filename is "main", then our replacement filename is "whisper-cli"
2323
if (filename == "main") {

examples/server/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(TARGET server)
1+
set(TARGET whisper-server)
22
add_executable(${TARGET} server.cpp httplib.h)
33

44
include(DefaultTargetOptions)
@@ -8,3 +8,5 @@ target_link_libraries(${TARGET} PRIVATE common json_cpp whisper ${CMAKE_THREAD_L
88
if (WIN32)
99
target_link_libraries(${TARGET} PRIVATE ws2_32)
1010
endif()
11+
12+
install(TARGETS ${TARGET} RUNTIME)

examples/server/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# whisper.cpp http server
1+
# whisper.cpp/examples/server
22

33
Simple http server. WAV Files are passed to the inference model via http requests.
44

@@ -7,9 +7,9 @@ https://github.com/ggerganov/whisper.cpp/assets/1991296/e983ee53-8741-4eb5-9048-
77
## Usage
88

99
```
10-
./server -h
10+
./build/bin/whisper-server -h
1111
12-
usage: ./bin/server [options]
12+
usage: ./build/bin/whisper-server [options]
1313
1414
options:
1515
-h, --help [default] show this help message and exit

examples/server/server.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,17 @@ int main(int argc, char ** argv) {
677677
if (sparams.ffmpeg_converter) {
678678
// if file is not wav, convert to wav
679679
// write to temporary file
680-
const std::string temp_filename_base = std::tmpnam(nullptr);
680+
//const std::string temp_filename_base = std::tmpnam(nullptr); // note: this is unsafe
681+
const std::string temp_filename_base = []() {
682+
char temp_filename_template[] = "/tmp/tempfileXXXXXX";
683+
int fd = mkstemp(temp_filename_template);
684+
if (fd == -1) {
685+
perror("mkstemp");
686+
return std::string();
687+
}
688+
close(fd);
689+
return std::string(temp_filename_template);
690+
}();
681691
const std::string temp_filename = temp_filename_base + ".wav";
682692
std::ofstream temp_file{temp_filename, std::ios::binary};
683693
temp_file << audio_file.content;
@@ -711,7 +721,6 @@ int main(int argc, char ** argv) {
711721
}
712722
}
713723

714-
715724
printf("Successfully loaded %s\n", filename.c_str());
716725

717726
// print system information

0 commit comments

Comments
 (0)