@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
63
63
thread_local wav_writer wavWriter;
64
64
std::string filename;
65
65
// 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 ());
67
67
68
68
if (opCode == uWS::OpCode::TEXT) {
69
69
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) {
89
89
// nlohmann::json response = {{"name",filename},{"signal", signal}};
90
90
nlohmann::json response = {{" name" , filename},
91
91
{" signal" , signal},
92
- {" result" , results }};
92
+ {" result" , final_results }};
93
93
ws->send (response.dump (), uWS::OpCode::TEXT);
94
94
}
95
95
// other process logic...
@@ -119,6 +119,7 @@ int main(int argc, char **argv) {
119
119
bool isOk = whisperService.process (audioBuffer.data (), audioBuffer.size ());
120
120
if (isOk) {
121
121
const int n_segments = whisper_full_n_segments (whisperService.ctx );
122
+ nlohmann::json results = nlohmann::json (nlohmann::json::array ());
122
123
for (int i = 0 ; i < n_segments; ++i) {
123
124
nlohmann::json segment;
124
125
int64_t t0 = whisper_full_get_segment_t0 (whisperService.ctx , i);
@@ -131,6 +132,7 @@ int main(int argc, char **argv) {
131
132
segment[" sentence" ] = sentence;
132
133
results.push_back (segment);
133
134
}
135
+ final_results=results;
134
136
response[" result" ] = results;
135
137
}
136
138
0 commit comments