Skip to content

Commit 71f12d3

Browse files
author
litongjava
committed
remove unused vad
1 parent 0eef537 commit 71f12d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+35
-10165
lines changed

client/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pip install soundfile
44
pip install websockets
55
```
66
```shell script
7-
python client\websocket_client.py --server_ip 192.168.3.7 --port 8090 --wavfile samples/jfk.wav
7+
python client\websocket_client.py --server_ip 127.0.0.1 --port 8090 --wavfile samples/jfk.wav
88
```
99
only save audio
1010
```shell script
11-
python client\websocket_client.py --server_ip 192.168.3.7 --port 8090 --endpoint /streaming/save --wavfile samples/jfk.wav
11+
python client\websocket_client.py --server_ip 127.0.0.1 --port 8090 --endpoint /streaming/save --wavfile samples/jfk.wav
1212
```

examples/audio_vad.cpp

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,91 +4,12 @@
44
#include <memory>
55
#include <filesystem>
66

7-
extern "C" {
8-
#include "simplevad/simple_vad.h"
9-
#include "simplevad/period_format.h"
10-
#include "simplevad/file_cut.h"
11-
}
12-
int run(FILE *fp, simple_vad *vad, struct cut_info *cut);
13-
14-
int add_period_activity(struct periods *per, int is_active, int is_last);
15-
16-
int main(int argc,char** argv) {
7+
int main(int argc, char **argv) {
178
//default cmake-build-debug/main
189
const char filename[] = "../pcm/16k_1.pcm";
1910
const char output_dir[] = "output_pcm";
2011
const char output_filename_prefix[] = "16k_1.pcm";
2112
if (!std::filesystem::exists(output_dir)) {
2213
std::filesystem::create_directories(output_dir);
2314
}
24-
25-
std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(filename, "rb"), &fclose);
26-
if (!fp) {
27-
std::cerr << filename << " does not exist\n";
28-
return 3;
29-
}
30-
31-
std::unique_ptr<simple_vad, decltype(&simple_vad_free)> vad(
32-
simple_vad_create(), &simple_vad_free);
33-
if (!vad) {
34-
return 4;
35-
}
36-
37-
std::unique_ptr<FILE, decltype(&fclose)> fp2(fopen(filename, "rb"), &fclose);
38-
std::unique_ptr<struct cut_info, decltype(&cut_info_free)> cut(cut_info_create(fp2.get()), &cut_info_free);
39-
40-
snprintf(cut->output_filename_prefix, sizeof(cut->output_filename_prefix), "%s",
41-
output_filename_prefix);
42-
snprintf(cut->output_file_dir, sizeof(cut->output_file_dir), "%s", output_dir);
43-
44-
int res = run(fp.get(), vad.get(), cut.get());
45-
46-
std::cout << "PROGRAM FINISH\n";
47-
return res;
48-
}
49-
50-
int run(FILE *fp, simple_vad *vad, struct cut_info *cut) {
51-
int16_t data[FRAME_SIZE];
52-
int res = 0;
53-
struct periods *per = periods_create();
54-
55-
while (res == 0) {
56-
res = read_int16_bytes(fp, data);
57-
if (res <= 1) {
58-
int is_last = (res == 1);
59-
int is_active = process_vad(vad, data);
60-
add_period_activity(per, is_active, is_last);
61-
int vad_file_res = cut_add_vad_activity(cut, is_active, is_last);
62-
if (vad_file_res < 0) {
63-
std::cout << "file write success " << cut->result_filename << "\n";
64-
}
65-
} else if (ferror(fp)) {
66-
std::cout << "read failed ferror result : " << ferror(fp) << "\n";
67-
}
68-
}
69-
70-
periods_free(per);
71-
72-
if (res != 1) {
73-
std::cerr << "read file error " << res << "\n";
74-
return res;
75-
}
76-
return 0;
77-
}
78-
79-
int add_period_activity(struct periods *per, int is_active, int is_last) {
80-
static int old_is_active = 0;
81-
static int count = 0;
82-
int res_add = period_add_vad_activity(per, is_active, is_last);
83-
if (res_add != 0) {
84-
return res_add;
85-
}
86-
if (is_active != old_is_active) {
87-
old_is_active = is_active;
88-
}
89-
count += 1;
90-
if (is_last) {
91-
//periods_print(per);
92-
std::cout << "total frames " << count << "\n";
93-
}
9415
}

simplevad/common.h

Lines changed: 0 additions & 51 deletions
This file was deleted.

simplevad/file_cut.c

Lines changed: 0 additions & 128 deletions
This file was deleted.

simplevad/file_cut.h

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)