Skip to content

Commit ca1b751

Browse files
committed
added speechmatics
added support for speechmatics to autoEdit, and test with 20 min video file, as well as added korean language to IBM Watson
1 parent be41224 commit ca1b751

20 files changed

+6576
-169
lines changed

electron/db.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ DB.create = function(model, success, error){
134134
// destFolder:"/media",
135135
tmpWorkFolder: tmpMediaFolder,
136136
destFolder: mediaFolder,
137-
keys: window.IBMWatsonKeys(),
137+
keys: {
138+
watson: window.IBMWatsonKeys(),
139+
speechmatics: window.SpeechmaticsKeys()
140+
},
138141
languageModel: newElement.languageModel,
139142
sttEngine: newElement.sttEngine,
140143
cbMetadata: function(respM) {

electron/index.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<li ><a href="#paperedits">Paperedits</a></li>
4444
<!-- settings -->
4545
<li ><a href="#settings"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></a></li>
46-
<li><a class="externalLink" href="https://donorbox.org/c9762eef-0e08-468e-90cb-2d00643697f8?recurring=true" class="custom-dbox-popup" target="_blank"><span class="glyphicon glyphicon-gift" aria-hidden="true"> Donate</a></li>
46+
<li><a class="externalLink" href="https://donorbox.org/c9762eef-0e08-468e-90cb-2d00643697f8?recurring=true" class="custom-dbox-popup" target="_blank"><span class="glyphicon glyphicon-gift" aria-hidden="true"></span> Donate</a></li>
4747

4848
<li class="dropdown">
4949
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Help
@@ -69,18 +69,23 @@
6969

7070
<!-- Setup database and nwjs stuff -->
7171
<script>
72+
"use strict";
7273
if (window.process !== undefined) {
7374
const {dialog} = require('electron').remote;
7475
console.debug("In Electron Enviroment");
7576
//TODO: rename across code base, perhaps use ENVIROMENT instead of this.
76-
window.frontEndEnviromentNWJS = true;
77+
window.frontEndEnviromentElectron = true;
7778
// window.nw = require('nw.gui');
7879
window.DB = require('./db.js');
7980

8081
window.IBMWatsonKeys = require('./watson_keys.js').getWatsonAPIkeys;
8182
window.setWatsonAPIkeys = require('./watson_keys.js').setWatsonAPIkeys;
8283
window.areWatsonAPIkeysSet = require('./watson_keys.js').areWatsonAPIkeysSet;
8384

85+
window.SpeechmaticsKeys = require('./speechmatics_keys.js').getSpeechmaticsAPIkeys;
86+
window.setSpeechmaticsAPIkeys = require('./speechmatics_keys.js').setSpeechmaticsAPIkeys;
87+
window.areSpeechmaticsAPIkeysSet = require('./speechmatics_keys.js').areSpeechmaticsAPIkeysSet;
88+
8489
// if you drag a file onto the app, it stops from the window opening that file.
8590
// TODO: it be awesome if whichever view you are in if you drag a file onto the window, it opens the transcription form view, with that file prepopulated.
8691
document.addEventListener('drop', function(e) {
@@ -95,7 +100,7 @@
95100

96101
} else {
97102
console.debug("In Browser Enviroment");
98-
window.frontEndEnviromentNWJS = false;
103+
window.frontEndEnviromentElectron = false;
99104
}
100105
</script>
101106

electron/speechmatics_keys.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"use strict";
2+
const fs = require('fs');
3+
const electron = require('electron');
4+
const currentWindow = electron.remote.getCurrentWindow();
5+
const path = require('path');
6+
7+
// var speechmaticsKeysPath;
8+
9+
if (window.process !== 'undefined') {
10+
var speechmaticsKeysPath = path.join(currentWindow.dataPath , 'speechmaticskeys.json');
11+
}else{
12+
//not in electron
13+
var speechmaticsKeysPath = "";
14+
}
15+
16+
var speechmaticsKeys = {username: "", password: ""};
17+
// var speechmaticsKeysSet = false;
18+
19+
// load keys on startup
20+
window.document.addEventListener('DOMContentLoaded', function() {
21+
if (areSpeechmaticsAPIkeysSet()) {
22+
speechmaticsKeys = getSpeechmaticsAPIkeys();
23+
}
24+
});
25+
26+
//helper funciton to check/validate the keys
27+
function keysAreValid(tempKeys){
28+
//if hte object has the required attributes
29+
if (tempKeys.username.length > 0 && tempKeys.password.length > 0) {
30+
return true;
31+
}else{
32+
return false;
33+
}
34+
}
35+
36+
// get
37+
function getSpeechmaticsAPIkeys(){
38+
if (fs.existsSync(speechmaticsKeysPath)) {
39+
speechmaticsKeys = JSON.parse(fs.readFileSync(speechmaticsKeysPath).toString());
40+
return speechmaticsKeys;
41+
}else{
42+
// fs.writeFileSync(speechmaticsKeysPath, JSON.strinfigy(getSpeechmaticsAPIkeys,null,2));
43+
return speechmaticsKeys;
44+
}
45+
}
46+
47+
//set
48+
function setSpeechmaticsAPIkeys(keys){
49+
if(keysAreValid(keys)){
50+
fs.writeFileSync(speechmaticsKeysPath, JSON.stringify(keys));
51+
}else{
52+
// not setting keys. should add some error handling it, but
53+
// at the moment validation check is handled in view
54+
}
55+
}
56+
57+
//check if they are set
58+
function areSpeechmaticsAPIkeysSet(){
59+
// fs.writeFileSync(speechmaticsKeysPath, JSON.stringify(tempKeys));
60+
if (fs.existsSync(speechmaticsKeysPath)) {
61+
// TODO: add some more validation that values actually make sense
62+
speechmaticsKeys = JSON.parse(fs.readFileSync(speechmaticsKeysPath).toString());
63+
var result = keysAreValid(speechmaticsKeys);
64+
// speechmaticsKeysSet = true;
65+
return result;
66+
} else {
67+
// speechmaticsKeysSet = false2;
68+
return false;
69+
}
70+
}
71+
72+
module.exports = {
73+
areSpeechmaticsAPIkeysSet: areSpeechmaticsAPIkeysSet,
74+
setSpeechmaticsAPIkeys: setSpeechmaticsAPIkeys,
75+
getSpeechmaticsAPIkeys: getSpeechmaticsAPIkeys
76+
};

electron/watson_keys.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
var fs = require('fs');
2-
var electron = require('electron');
3-
var currentWindow = electron.remote.getCurrentWindow();
1+
"use strict";
2+
const fs = require('fs');
3+
const electron = require('electron');
4+
const currentWindow = electron.remote.getCurrentWindow();
5+
const path = require('path');
6+
7+
var watsonKeysPath;
48

59
if (window.process !== 'undefined') {
6-
var watsonKeysPath = currentWindow.dataPath + '/wttskeys.json';
10+
var watsonKeysPath = path.join(currentWindow.dataPath , 'wttskeys.json');
711
}else{
8-
//not in nwjs
9-
var watsonKeysPath = "/";
12+
//not in electron
13+
var watsonKeysPath = "";
1014
}
1115

1216
var watsonKeys = {username: "", password: ""};
13-
var watsonKeysSet = false;
17+
// var watsonKeysSet = false;
1418

1519
// load keys on startup
1620
window.document.addEventListener('DOMContentLoaded', function() {

lib/app/router.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ var render = require('./views/utils').render;
1010

1111
var SettingsView = require('./views/settings_view');
1212

13-
14-
// var watsonKeysPath = window.nw.App.dataPath + '/wttskeys.json';
15-
if (typeof window.nw !== 'undefined') {
16-
var watsonKeysPath = window.nw.App.dataPath + '/wttskeys.json';
17-
}else{
18-
//not in nwjs
19-
var watsonKeysPath = "/";
20-
}
21-
2213
/**
2314
* Render a string or view to the main container on the page
2415
* @param {(Object|String)} string_or_view A string or backbone view
@@ -95,7 +86,7 @@ module.exports = Backbone.Router.extend({
9586

9687
settingsPanel: function(){
9788
console.debug('Router: settings panel: ');
98-
var tmpSettings ={credentials: {ibm: window.IBMWatsonKeys() }} ;
89+
var tmpSettings ={credentials: {ibm: window.IBMWatsonKeys(), speechmatics: window.SpeechmaticsKeys() }} ;
9990
var settingsView = new SettingsView({settings: tmpSettings});
10091
displayMain(settingsView);
10192
},

lib/app/templates/paperedit_form_template.html.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="container">
22
<!-- Demo notice -->
3-
<% if(!window.frontEndEnviromentNWJS ){%>
3+
<% if(!window.frontEndEnviromentElectron ){%>
44
<div class="alert alert-warning alert-dismissible" role="alert">
55
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
66
<strong>You are viewing the app in demo mode</strong>.<br>
Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="container">
22

33
<!-- Demo notice -->
4-
<% if(!window.frontEndEnviromentNWJS ){%>
4+
<% if(!window.frontEndEnviromentElectron ){%>
55
<div class="alert alert-warning alert-dismissible" role="alert">
66
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
77
<strong>You are viewing the app in demo mode</strong>.<br>
@@ -19,35 +19,84 @@
1919
</ol>
2020
<!-- end Breadcrumb -->
2121

22-
<div class="alert alert-info alert-dismissable">
23-
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
24-
<strong>IBM Watson Speech To Text Service Credentials</strong>
25-
<p>Here you can check or edit your credentials for the IBM Speech To Text service.</p>
26-
<p>Note that these are different from your IBM bluemix credentials. </p>
27-
<p>You need to activate a Watson Speech To Text Service on Bluemix to get these.</p>
28-
<p><a href="https://pietropassarelli.gitbooks.io/autoedit2-user-manual/setup-stt-apis/setup-stt-apis-ibm.html" class="alert-link" target="_blank">Checkout the user manual for more info</a>.</p>
29-
</div>
30-
22+
<div>
23+
24+
<!-- Nav tabs -->
25+
<ul class="nav nav-tabs" role="tablist">
26+
<li role="presentation" class="active"><a href="#ibm" aria-controls="ibm" role="tab" data-toggle="tab">IBM</a></li>
27+
<li role="presentation"><a href="#speechmatics" aria-controls="speechmatics" role="tab" data-toggle="tab">Speechmatics</a></li>
28+
<!-- <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li> -->
29+
</ul>
3130

31+
<!-- Tab panes -->
32+
<div class="tab-content">
33+
<div role="tabpanel" class="tab-pane active" id="ibm">
34+
<br>
35+
<div class="alert alert-info alert-dismissable">
36+
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
37+
<strong>IBM Watson Speech To Text Service Credentials</strong>
38+
<p>Here you can check or edit your credentials for the IBM Speech To Text service.</p>
39+
<p>Note that these are different from your IBM bluemix credentials. </p>
40+
<p>You need to activate a Watson Speech To Text Service on Bluemix to get these.</p>
41+
<p><a href="https://pietropassarelli.gitbooks.io/autoedit2-user-manual/setup-stt-apis/setup-stt-apis-ibm.html" class="alert-link" target="_blank">Checkout the user manual for more info</a>.</p>
42+
</div>
43+
44+
<!-- IBM credentials form -->
3245
<form id="form">
33-
<!-- File "upload" -->
3446
<div class="row">
3547
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
3648
<h3>IBM Watson Speech to text Service credentials</h3>
3749
<div class="form-group">
3850
<label for="username">IBM STT Username</label>
39-
<input type="title" name="username" value="<%= credentials.ibm.username %>" class="form-control" id="username" placeholder="e.g. PMYs8ZexZ7qKGkFgFJhGMYhqzEC4aNzRAv9H">
51+
<input type="title" name="username-ibm" value="<%= credentials.ibm.username %>" class="form-control" id="username" placeholder="e.g. PMYs8ZexZ7qKGkFgFJhGMYhqzEC4aNzRAv9H">
4052
</div>
4153
<div class="form-group">
4254
<label for="password">IBM STT Password</label>
43-
<input type="title" name="password" value="<%= credentials.ibm.password %>" class="form-control" id="password" placeholder="e.g. 2QKJ79uRsD2a">
55+
<input type="title" name="password-ibm" value="<%= credentials.ibm.password %>" class="form-control" id="password" placeholder="e.g. 2QKJ79uRsD2a">
4456
</div>
57+
<a id="submitBtnIbmCredentials" class="btn btn-primary">Save Credentials</a>
58+
</div><!-- ./col -->
59+
</div><!-- ./row -->
60+
</form>
61+
</div><!-- IBM tab -->
62+
63+
64+
<div role="tabpanel" class="tab-pane" id="speechmatics">
65+
<br>
66+
<div class="alert alert-info alert-dismissable">
67+
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
68+
<strong>Speechmatics Speech To Text Service Credentials</strong>
69+
<p>Here you can check or edit your credentials for the Speechmatics Speech To Text service.</p>
70+
<p>Note that these are different from your Speechmatics account login credentials. </p>
71+
<p>You need to activate the Speechmatics Speech To Text Service API to get these.</p>
72+
<p><a href="https://pietropassarelli.gitbooks.io/autoedit2-user-manual/setup-stt-apis/setup-stt-apis-speechmatics.html" class="alert-link" target="_blank">Checkout the user manual for more info</a>.</p>
73+
</div>
4574

46-
<!-- Save -->
47-
<!-- <a id="submitBtn" class="btn btn-primary">Save Transcription</a> -->
48-
<a id="submitBtn" class="btn btn-primary">Save Credentials</a>
49-
<!-- <a id="cancel" class="btn btn-default" href="#transcriptions">Cancel</a> -->
75+
76+
<!-- Speechmatics credentials form -->
77+
<form id="form">
78+
<div class="row">
79+
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
80+
<h3>Speechmatics Speech to text Service credentials</h3>
81+
<div class="form-group">
82+
<label for="username">Speechmatics STT Username</label>
83+
<input type="title" name="username-speechmatics" value="<%= credentials.speechmatics.username %>" class="form-control" id="username" placeholder="e.g. 72249">
84+
</div>
85+
<div class="form-group">
86+
<label for="password">Speechmatics STT Password</label>
87+
<input type="title" name="password-speechmatics" value="<%= credentials.speechmatics.password %>" class="form-control" id="password" placeholder="e.g. dYsaEPJZGzjdAEfW3R4oRXDaMkPwb9aqxDMwwMrekRAAnDxP">
88+
</div>
89+
<a id="submitBtnSpeechmaticsCredentials" class="btn btn-primary">Save Credentials</a>
5090
</div><!-- ./col -->
5191
</div><!-- ./row -->
5292
</form>
93+
</div> <!-- Speechmatics tab -->
94+
95+
96+
<!-- <div role="tabpanel" class="tab-pane" id="settings">...</div> -->
97+
</div>
98+
99+
</div>
100+
101+
53102
</div>

0 commit comments

Comments
 (0)