Skip to content

Commit e4f729a

Browse files
author
litongmacos
committed
add source event stream
1 parent d0eb6b0 commit e4f729a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

handler/inference_handler.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ using json = nlohmann::json;
1010
struct whisper_print_user_data {
1111
const whisper_params *params;
1212

13-
const std::vector <std::vector<float>> *pcmf32s;
13+
const std::vector<std::vector<float>> *pcmf32s;
1414
int progress_prev;
1515
};
1616

1717
// Terminal color map. 10 colors grouped in ranges [0.0, 0.1, ..., 0.9]
1818
// Lowest is red, middle is yellow, highest is green.
19-
const std::vector <std::string> k_colors = {
19+
const std::vector<std::string> k_colors = {
2020
"\033[38;5;196m", "\033[38;5;202m", "\033[38;5;208m", "\033[38;5;214m", "\033[38;5;220m",
2121
"\033[38;5;226m", "\033[38;5;190m", "\033[38;5;154m", "\033[38;5;118m", "\033[38;5;82m",
2222
};
@@ -27,7 +27,7 @@ int timestamp_to_sample(int64_t t, int n_samples) {
2727
}
2828

2929
std::string
30-
estimate_diarization_speaker(std::vector <std::vector<float>> pcmf32s, int64_t t0, int64_t t1, bool id_only = false) {
30+
estimate_diarization_speaker(std::vector<std::vector<float>> pcmf32s, int64_t t0, int64_t t1, bool id_only = false) {
3131
std::string speaker = "";
3232
const int64_t n_samples = pcmf32s[0].size();
3333

@@ -132,7 +132,7 @@ void whisper_print_segment_callback(struct whisper_context *ctx, struct whisper_
132132
}
133133

134134
std::string
135-
output_str(struct whisper_context *ctx, const whisper_params &params, std::vector <std::vector<float>> pcmf32s) {
135+
output_str(struct whisper_context *ctx, const whisper_params &params, std::vector<std::vector<float>> pcmf32s) {
136136
std::stringstream result;
137137
const int n_segments = whisper_full_n_segments(ctx);
138138
for (int i = 0; i < n_segments; ++i) {
@@ -199,7 +199,7 @@ void getReqParameters(const Request &req, whisper_params &params) {
199199
}
200200

201201
bool read_audio_file(std::string audio_format, std::string filename, std::vector<float> &pcmf32,
202-
std::vector <std::vector<float>> &pcmf32s, bool diarize) {
202+
std::vector<std::vector<float>> &pcmf32s, bool diarize) {
203203

204204
// read audio content into pcmf32
205205
if (audio_format == "mp3") {
@@ -222,7 +222,7 @@ bool read_audio_file(std::string audio_format, std::string filename, std::vector
222222
}
223223

224224
bool run(std::mutex &whisper_mutex, whisper_params &params, whisper_context *ctx, std::string filename,
225-
const std::vector <std::vector<float>> &pcmf32s, std::vector<float> pcmf32) {
225+
const std::vector<std::vector<float>> &pcmf32s, std::vector<float> pcmf32) {
226226
// print system information
227227
{
228228
fprintf(stderr, "\n");
@@ -372,7 +372,7 @@ void handleInference(const Request &request, Response &response, std::mutex &whi
372372

373373
// audio arrays
374374
std::vector<float> pcmf32; // mono-channel F32 PCM
375-
std::vector <std::vector<float>> pcmf32s; // stereo-channel F32 PCM
375+
std::vector<std::vector<float>> pcmf32s; // stereo-channel F32 PCM
376376

377377
// write file to temporary file
378378
std::ofstream temp_file{filename, std::ios::binary};

0 commit comments

Comments
 (0)