online-tcp-source.h
Go to the documentation of this file.
1 // online/online-tcp-source.h
2 
3 // Copyright 2013 Polish-Japanese Institute of Information Technology (author: Danijel Korzinek)
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 #ifndef KALDI_ONLINE_ONLINE_TCP_SOURCE_H_
21 #define KALDI_ONLINE_ONLINE_TCP_SOURCE_H_
22 
23 #if !defined(_MSC_VER)
24 
25 #include "online-audio-source.h"
26 #include "matrix/kaldi-vector.h"
27 
28 namespace kaldi {
29 /*
30  * This class implements a VectorSource that reads audio data in a special format from a socket descriptor.
31  *
32  * The documentation and "interface" for this class is given in online-audio-source.h
33  */
35  public:
38 
39  // Implementation of the OnlineAudioSourceItf
40  bool Read(Vector<BaseFloat> *data);
41 
42  //returns if the socket is still connected
43  bool IsConnected();
44 
45  //returns the number of samples read since the last reset
46  size_t SamplesProcessed();
47  //resets the number of samples
48  void ResetSamples();
49 
50  private:
52  bool connected;
53  char* pack;
55  char* frame;
57 
59 
61 
62  //runs the built-in "read" method as many times as needed to fill "buf" with "len" bytes
63  bool ReadFull(char* buf, int32 len);
64  //gets the next packet of bytes and returns its size
66  //runs "getNextPack" enough times to fill the frame with "size" bytes
67  int32 FillFrame(int32 size);
68 
70 };
71 
72 } // namespace kaldi
73 
74 #endif // !defined(_MSC_VER)
75 
76 #endif // KALDI_ONLINE_ONLINE_TCP_SOURCE_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
bool Read(Vector< BaseFloat > *data)
KALDI_DISALLOW_COPY_AND_ASSIGN(OnlineTcpVectorSource)
kaldi::int32 int32
bool ReadFull(char *buf, int32 len)
A class representing a vector.
Definition: kaldi-vector.h:406