5
5
6
6
//
7
7
// This file demonstrates how to use streaming Zipformer with sherpa-onnx's C
8
- // and with tokens and hotwords loaded from buffered strings instead of from external
9
- // files API.
8
+ // and with tokens and hotwords loaded from buffered strings instead of from
9
+ // external files API.
10
10
// clang-format off
11
11
//
12
12
// wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17.tar.bz2
22
22
#include "sherpa-onnx/c-api/c-api.h"
23
23
24
24
static size_t ReadFile (const char * filename , const char * * buffer_out ) {
25
- FILE * file = fopen (filename , "rb " );
25
+ FILE * file = fopen (filename , "r " );
26
26
if (file == NULL ) {
27
27
fprintf (stderr , "Failed to open %s\n" , filename );
28
28
return -1 ;
@@ -39,7 +39,7 @@ static size_t ReadFile(const char *filename, const char **buffer_out) {
39
39
size_t read_bytes = fread (* buffer_out , 1 , size , file );
40
40
if (read_bytes != size ) {
41
41
printf ("Errors occured in reading the file %s\n" , filename );
42
- free (* buffer_out );
42
+ free (( void * ) * buffer_out );
43
43
* buffer_out = NULL ;
44
44
fclose (file );
45
45
return -1 ;
@@ -80,14 +80,14 @@ int32_t main() {
80
80
size_t token_buf_size = ReadFile (tokens_filename , & tokens_buf );
81
81
if (token_buf_size < 1 ) {
82
82
fprintf (stderr , "Please check your tokens.txt!\n" );
83
- free (tokens_buf );
83
+ free (( void * ) tokens_buf );
84
84
return -1 ;
85
85
}
86
86
const char * hotwords_buf ;
87
87
size_t hotwords_buf_size = ReadFile (hotwords_filename , & hotwords_buf );
88
88
if (hotwords_buf_size < 1 ) {
89
89
fprintf (stderr , "Please check your hotwords.txt!\n" );
90
- free (hotwords_buf );
90
+ free (( void * ) hotwords_buf );
91
91
return -1 ;
92
92
}
93
93
@@ -119,9 +119,9 @@ int32_t main() {
119
119
SherpaOnnxOnlineRecognizer * recognizer =
120
120
SherpaOnnxCreateOnlineRecognizer (& recognizer_config );
121
121
122
- free (tokens_buf );
122
+ free (( void * ) tokens_buf );
123
123
tokens_buf = NULL ;
124
- free (hotwords_buf );
124
+ free (( void * ) hotwords_buf );
125
125
hotwords_buf = NULL ;
126
126
127
127
if (recognizer == NULL ) {
@@ -199,4 +199,4 @@ int32_t main() {
199
199
fprintf (stderr , "\n" );
200
200
201
201
return 0 ;
202
- }
202
+ }
0 commit comments