Skip to content

Commit c8967c3

Browse files
authored
Merge pull request #150 from hyperaudio/149-dpe-support
DPE JSON support
2 parents 9faf26d + cd6d219 commit c8967c3

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

wp-hyperaudio/hyperaudio-admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ function hyperaudio_options_page()
259259
<option value="oe">OpenEditor JSON</option>
260260
<option value="srt">SRT formatted captions</option>
261261
<option value="speechmatics">Speechmatics JSON</option>
262+
<option value="dpe">DPE JSON</option>
262263
<option value="gentle">Gentle JSON</option>
263264
<option value="google">Google Speech-to-Text</option>
264265
<option value="other">Other</option>

wp-hyperaudio/hyperaudio.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Hyperaudio Interactive Transcript
44
* Plugin URI: https://hyper.audio
55
* Description: Hyperaudio Interactive Transcript Maker and Player – maximise your audio and video content's accessibility to humans and search engines.
6-
* Version: 1.0.22
6+
* Version: 1.0.23
77
* Author: Mark Boas
88
* Author URI: https://maboa.it
99
**/

wp-hyperaudio/js/converter.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,47 @@ $(document).ready(function() {
373373
ht = items.join('');
374374
break;
375375

376+
case 'dpe':
377+
var data = JSON.parse(input);
378+
379+
var words = data.words;
380+
var paras = data.paragraphs;
381+
var items = ['<article><section>'];
382+
383+
$.each(words, function(i, word) {
384+
385+
$.each(paras, function(j, para) {
386+
if (word.start === para.start) {
387+
items.push("<p>");
388+
389+
if (para.speaker.length > 0){
390+
items.push('<span class="speaker" data-m="'+Math.round(para.start * 1000)+'" data-d="0">['+para.speaker+'] </span>');
391+
}
392+
}
393+
});
394+
395+
items.push(
396+
'<span data-m="' +
397+
Math.round(word.start * 1000) +
398+
'" data-d="' +
399+
Math.round((word.end - word.start) * 1000) +
400+
'">' +
401+
word.text + " " +
402+
' </span>'
403+
);
404+
405+
$.each(paras, function(j, para) {
406+
if (word.end === para.end) {
407+
items.push("<p>");
408+
}
409+
});
410+
});
411+
412+
items.push('</section></article>');
413+
414+
ht = items.join('');
415+
break;
416+
376417
case 'gentle':
377418
var data = JSON.parse(input);
378419

0 commit comments

Comments
 (0)