Skip to content

Commit 09bfaf9

Browse files
author
litongmacos
committed
add get_current_time_mills
1 parent 0505dc7 commit 09bfaf9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

whisper_server_base_on_uwebsockets.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
6363
thread_local wav_writer wavWriter;
6464
std::string filename;
6565
//std::unique_ptr<nlohmann::json> results(new nlohmann::json(nlohmann::json::array()));
66-
nlohmann::json results = nlohmann::json(nlohmann::json::array());
66+
nlohmann::json final_results = nlohmann::json(nlohmann::json::array());
6767

6868
if (opCode == uWS::OpCode::TEXT) {
6969
printf("%s: Received message on /paddlespeech/asr/streaming: %s\n", get_current_time().c_str(),
@@ -89,7 +89,7 @@ int main(int argc, char **argv) {
8989
// nlohmann::json response = {{"name",filename},{"signal", signal}};
9090
nlohmann::json response = {{"name", filename},
9191
{"signal", signal},
92-
{"result", results}};
92+
{"result", final_results}};
9393
ws->send(response.dump(), uWS::OpCode::TEXT);
9494
}
9595
// other process logic...
@@ -119,6 +119,7 @@ int main(int argc, char **argv) {
119119
bool isOk = whisperService.process(audioBuffer.data(), audioBuffer.size());
120120
if (isOk) {
121121
const int n_segments = whisper_full_n_segments(whisperService.ctx);
122+
nlohmann::json results = nlohmann::json(nlohmann::json::array());
122123
for (int i = 0; i < n_segments; ++i) {
123124
nlohmann::json segment;
124125
int64_t t0 = whisper_full_get_segment_t0(whisperService.ctx, i);
@@ -131,6 +132,7 @@ int main(int argc, char **argv) {
131132
segment["sentence"] = sentence;
132133
results.push_back(segment);
133134
}
135+
final_results=results;
134136
response["result"] = results;
135137
}
136138

0 commit comments

Comments
 (0)