@@ -5,25 +5,28 @@ A small library which can parse TextGrid into json and json into TextGrid
5
5
6
6
## Getting Started
7
7
### On the server
8
- Install the module with: ` npm install textgrid `
8
+ Install the module with: ` npm install textgrid --save `
9
9
10
10
``` javascript
11
11
var textgrid = require (' textgrid' );
12
12
textgrid .init (); // "init"
13
13
```
14
14
15
15
### In the browser
16
+
17
+ Install the module with: ` bower install textgrid --save ` or,
18
+
16
19
Download the [ production version] [ min ] or the [ development version] [ max ] .
17
20
18
21
[ min ] : https://raw.github.com/OpenSourceFieldlinguistics/PraatTextGridJS/master/dist/textgrid.min.js
19
22
[ max ] : https://raw.github.com/OpenSourceFieldlinguistics/PraatTextGridJS/master/dist/textgrid.js
20
23
21
- In your web page :
24
+ In your web app :
22
25
23
26
``` html
24
- <script src =" dist/textgrid.min.js" ></script >
27
+ <script src =" bower_components/textgrid/ dist/textgrid.min.js" ></script >
25
28
<script >
26
- init (); // "init"
29
+ var textgridAsJson = TextGrid . textgridToIGT (originalTextGridAsText);
27
30
</script >
28
31
```
29
32
@@ -33,25 +36,83 @@ In your code, you can attach textgrid's methods to any object.
33
36
<script >
34
37
var exports = Bocoup .utils ;
35
38
</script >
36
- <script src =" dist/textgrid.min.js" ></script >
39
+ <script src =" bower_components/textgrid/ dist/textgrid.min.js" ></script >
37
40
<script >
38
- Bocoup .utils .init ( ); // "init"
41
+ var textgridAsJson = Bocoup .utils .textgridToIGT (originalTextGridAsText ); // "init"
39
42
</script >
40
43
```
41
44
45
+ An example of what you can do with the result.
46
+
47
+ ``` js
48
+ var textgrid = TextGrid .textgridToIGT (text);
49
+ if (textgrid .isIGTNestedOrAlignedOrBySpeaker .probablyAligned ) {
50
+ for (itemIndex in textgrid .intervalsByXmin ) {
51
+ if (! textgrid .intervalsByXmin .hasOwnProperty (itemIndex)) {
52
+ continue ;
53
+ }
54
+ if (textgrid .intervalsByXmin [itemIndex]) {
55
+ row = {};
56
+ for (intervalIndex = 0 ; intervalIndex < textgrid .intervalsByXmin [itemIndex].length ; intervalIndex++ ) {
57
+ interval = textgrid .intervalsByXmin [itemIndex][intervalIndex];
58
+ row .startTime = row .startTime ? row .startTime : interval .xmin ;
59
+ row .endTime = row .endTime ? row .endTime : interval .xmax ;
60
+ row .utterance = row .utterance ? row .utterance : interval .text .trim ();
61
+ row .modality = " spoken" ;
62
+ row .tier = interval .tierName ;
63
+ row .speakers = interval .speaker ;
64
+ row .audioFileName = interval .fileName || audioFileName;
65
+ row .CheckedWithConsultant = interval .speaker ;
66
+ consultants .push (row .speakers );
67
+ row[interval .tierName ] = interval .text ;
68
+ header .push (interval .tierName );
69
+ }
70
+ matrix .push (row);
71
+ }
72
+ }
73
+ } else {
74
+ for (itemIndex in textgrid .intervalsByXmin ) {
75
+ if (! textgrid .intervalsByXmin .hasOwnProperty (itemIndex)) {
76
+ continue ;
77
+ }
78
+ if (textgrid .intervalsByXmin [itemIndex]) {
79
+ for (intervalIndex = 0 ; intervalIndex < textgrid .intervalsByXmin [itemIndex].length ; intervalIndex++ ) {
80
+ row = {};
81
+ interval = textgrid .intervalsByXmin [itemIndex][intervalIndex];
82
+ row .startTime = row .startTime ? row .startTime : interval .xmin ;
83
+ row .endTime = row .endTime ? row .endTime : interval .xmax ;
84
+ row .utterance = row .utterance ? row .utterance : interval .text .trim ();
85
+ row .modality = " spoken" ;
86
+ row .tier = interval .tierName ;
87
+ row .speakers = interval .speaker ;
88
+ row .audioFileName = interval .fileName || audioFileName;
89
+ row .CheckedWithConsultant = interval .speaker ;
90
+ consultants .push (row .speakers );
91
+ row[interval .tierName ] = interval .text ;
92
+ header .push (interval .tierName );
93
+ matrix .push (row);
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ ```
100
+
42
101
## Documentation
43
- _ (Coming soon) _
102
+ http://opensourcefieldlinguistics.github.io/FieldDB/
44
103
45
104
## Examples
46
- _ (Coming soon) _
105
+ See tests directory for more ways to use the library
47
106
48
107
## Contributing
49
108
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [ Grunt] ( http://gruntjs.com/ ) .
50
109
51
- _ Also, please don't edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "lib" subdirectory!_
110
+ _ The "dist" subdirectory files are generated via Grunt. You'll find source code in the "lib" subdirectory!_
52
111
53
112
## Release History
54
- _ (Nothing yet)_
113
+ * v1.102.3 April 22 2014 Long audio import support
114
+ * v2.2.0 April 22 2014 Support for multiple small files each corresponding to an utterance
115
+
55
116
56
117
## License
57
118
Copyright (c) 2014 OpenSourceFieldLinguistics Contribs
0 commit comments