Kaldi
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
*/
34
class
OnlineTcpVectorSource
:
public
OnlineAudioSourceItf
{
35
public
:
36
OnlineTcpVectorSource
(
int32
socket);
37
~OnlineTcpVectorSource
();
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
:
51
int32
socket_desc
;
52
bool
connected
;
53
char
*
pack
;
54
int32
pack_size
;
55
char
*
frame
;
56
int32
frame_size
;
57
58
int32
last_pack_size
,
last_pack_rem
;
59
60
size_t
samples_processed
;
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
65
int32
GetNextPack
();
66
//runs "getNextPack" enough times to fill the frame with "size" bytes
67
int32
FillFrame
(
int32
size);
68
69
KALDI_DISALLOW_COPY_AND_ASSIGN
(
OnlineTcpVectorSource
);
70
};
71
72
}
// namespace kaldi
73
74
#endif // !defined(_MSC_VER)
75
76
#endif // KALDI_ONLINE_ONLINE_TCP_SOURCE_H_
kaldi::OnlineTcpVectorSource::SamplesProcessed
size_t SamplesProcessed()
Definition:
online-tcp-source.cc:46
online-audio-source.h
kaldi
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition:
chain.dox:20
kaldi::OnlineTcpVectorSource::frame
char * frame
Definition:
online-tcp-source.h:55
kaldi::OnlineTcpVectorSource::samples_processed
size_t samples_processed
Definition:
online-tcp-source.h:60
kaldi::OnlineTcpVectorSource::Read
bool Read(Vector< BaseFloat > *data)
Definition:
online-tcp-source.cc:125
kaldi::OnlineTcpVectorSource::KALDI_DISALLOW_COPY_AND_ASSIGN
KALDI_DISALLOW_COPY_AND_ASSIGN(OnlineTcpVectorSource)
kaldi::OnlineTcpVectorSource::OnlineTcpVectorSource
OnlineTcpVectorSource(int32 socket)
Definition:
online-tcp-source.cc:29
kaldi::OnlineTcpVectorSource
Definition:
online-tcp-source.h:34
kaldi::int32
kaldi::int32 int32
Definition:
online-tcp-source.cc:27
kaldi::OnlineTcpVectorSource::ReadFull
bool ReadFull(char *buf, int32 len)
Definition:
online-tcp-source.cc:53
kaldi::OnlineTcpVectorSource::pack_size
int32 pack_size
Definition:
online-tcp-source.h:54
kaldi::OnlineTcpVectorSource::last_pack_size
int32 last_pack_size
Definition:
online-tcp-source.h:58
kaldi::OnlineTcpVectorSource::FillFrame
int32 FillFrame(int32 size)
Definition:
online-tcp-source.cc:93
kaldi::OnlineAudioSourceItf
Definition:
online-audio-source.h:37
kaldi-vector.h
kaldi::OnlineTcpVectorSource::socket_desc
int32 socket_desc
Definition:
online-tcp-source.h:51
kaldi::OnlineTcpVectorSource::~OnlineTcpVectorSource
~OnlineTcpVectorSource()
Definition:
online-tcp-source.cc:41
kaldi::OnlineTcpVectorSource::last_pack_rem
int32 last_pack_rem
Definition:
online-tcp-source.h:58
kaldi::OnlineTcpVectorSource::connected
bool connected
Definition:
online-tcp-source.h:52
kaldi::OnlineTcpVectorSource::GetNextPack
int32 GetNextPack()
Definition:
online-tcp-source.cc:71
kaldi::OnlineTcpVectorSource::frame_size
int32 frame_size
Definition:
online-tcp-source.h:56
kaldi::OnlineTcpVectorSource::ResetSamples
void ResetSamples()
Definition:
online-tcp-source.cc:49
kaldi::Vector
A class representing a vector.
Definition:
kaldi-vector.h:406
kaldi::OnlineTcpVectorSource::pack
char * pack
Definition:
online-tcp-source.h:53
kaldi::OnlineTcpVectorSource::IsConnected
bool IsConnected()
Definition:
online-tcp-source.cc:151
online
online-tcp-source.h
Generated by
1.8.13