Skip to content

Commit

Permalink
DPE JSON support
Browse files Browse the repository at this point in the history
  • Loading branch information
maboa committed Feb 5, 2024
1 parent 9faf26d commit cd6d219
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions wp-hyperaudio/hyperaudio-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ function hyperaudio_options_page()
<option value="oe">OpenEditor JSON</option>
<option value="srt">SRT formatted captions</option>
<option value="speechmatics">Speechmatics JSON</option>
<option value="dpe">DPE JSON</option>
<option value="gentle">Gentle JSON</option>
<option value="google">Google Speech-to-Text</option>
<option value="other">Other</option>
Expand Down
2 changes: 1 addition & 1 deletion wp-hyperaudio/hyperaudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Hyperaudio Interactive Transcript
* Plugin URI: https://hyper.audio
* Description: Hyperaudio Interactive Transcript Maker and Player – maximise your audio and video content's accessibility to humans and search engines.
* Version: 1.0.22
* Version: 1.0.23
* Author: Mark Boas
* Author URI: https://maboa.it
**/
Expand Down
41 changes: 41 additions & 0 deletions wp-hyperaudio/js/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,47 @@ $(document).ready(function() {
ht = items.join('');
break;

case 'dpe':
var data = JSON.parse(input);

var words = data.words;
var paras = data.paragraphs;
var items = ['<article><section>'];

$.each(words, function(i, word) {

$.each(paras, function(j, para) {
if (word.start === para.start) {
items.push("<p>");

if (para.speaker.length > 0){
items.push('<span class="speaker" data-m="'+Math.round(para.start * 1000)+'" data-d="0">['+para.speaker+'] </span>');
}
}
});

items.push(
'<span data-m="' +
Math.round(word.start * 1000) +
'" data-d="' +
Math.round((word.end - word.start) * 1000) +
'">' +
word.text + " " +
' </span>'
);

$.each(paras, function(j, para) {
if (word.end === para.end) {
items.push("<p>");
}
});
});

items.push('</section></article>');

ht = items.join('');
break;

case 'gentle':
var data = JSON.parse(input);

Expand Down

0 comments on commit cd6d219

Please sign in to comment.