File: tokenstream_istream.diff

package info (click to toggle)
speech-tools 1%3A2.5.0-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,040 kB
  • sloc: cpp: 67,350; ansic: 12,174; sh: 4,055; java: 3,748; makefile: 1,106; lisp: 711; perl: 396; awk: 85; xml: 9
file content (48 lines) | stat: -rw-r--r-- 1,433 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
This patch provides a seeking and reading interface to istreams in the 
EST_TokenStream class.
This patch is required by the htsperformance.diff patch in Festival
in order to reduce the i/o disk usage when using HTS voices.
This patch is not intended to alter the code in a substantive way.
No copyright subsists in this patch as it is too trivial.

Author: Sergio Oller <sergioller@gmail.com>
Applied-Upstream: https://github.com/festvox/speech_tools/pull/23

--- a/base_class/EST_Token.cc
+++ b/base_class/EST_Token.cc
@@ -287,8 +287,9 @@
 	return -1;
 	break;
       case tst_istream:
-	cerr << "EST_TokenStream seek on istream not yet supported" << endl;
-	return -1;
+    is->seekg(0,is->end);
+    p_filepos = is->tellg();
+	return p_filepos;
 	break;
       case tst_string:
 	pos = buffer_length;
@@ -320,8 +321,9 @@
 	return -1;
 	break;
       case tst_istream:
-	cerr << "EST_TokenStream seek on istream not yet supported" << endl;
-	return -1;
+    p_filepos = position;
+    is->seekg(position, is->beg);
+	return 0;
 	break;
       case tst_string:
 	if (position >= pos)
@@ -381,8 +383,9 @@
 	return 0;
 	break;
       case tst_istream:
-	cerr << "EST_TokenStream fread istream not yet supported" << endl;
-	return 0;
+    is->read((char*)buff, (size_t) size*nitems);
+	return is->gcount()/size;
+    break;
       case tst_string:
 	if ((buffer_length-pos)/size < nitems)
 	    items_read = (buffer_length-pos)/size;