server : use OS-generated temp file name for converted files (#2419)

This commit is contained in:
Toliver 2024-09-17 21:56:32 +09:00 committed by GitHub
parent 049b3a0e53
commit 5b1ce40fa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -677,7 +677,8 @@ int main(int argc, char ** argv) {
if (sparams.ffmpeg_converter) {
// if file is not wav, convert to wav
// write to temporary file
const std::string temp_filename = "whisper_server_temp_file.wav";
const std::string temp_filename_base = std::tmpnam(nullptr);
const std::string temp_filename = temp_filename_base + ".wav";
std::ofstream temp_file{temp_filename, std::ios::binary};
temp_file << audio_file.content;
temp_file.close();