-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
96 lines (78 loc) · 2.67 KB
/
index.html
File metadata and controls
96 lines (78 loc) · 2.67 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./lib/bootstrap.min.css">
<title>Document</title>
</head>
<body>
<div class="jumbotron text-center">
<h1>Speech to text</h1>
<p>Upload audio and hit convert to get its text.</p>
</div>
<div class="container">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<a href="#" class="card-link"><input type="file" accept="audio/*" id="file-chooser"></a>
<a href="#" class="card-link" id="transcribe-btn">Start transcribing</a>
<h4 class="card-title">Start by uploading audio</h4>
<small class="text-muted" id="target"></small>
<p class="card-text" id="outputText"></p>
</div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="col-sm-4 offset-sm-4">
<form class="form-inline">
<input type="file" accept="audio/*">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<h1 id="target"></h1>
<h6 id="outputText"></h6>
</div> -->
</div>
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="./lib/jquery-3.3.1.min.js"></script>
<script src="./lib/watson-speech.js"></script>
<script>if (window.module) module = window.module;</script>
<script>
const electron = require('electron');
const { ipcRenderer } = electron;
/**Get token for watson */
var tokenText;
ipcRenderer.on('watson:token', (event, token)=>{
tokenText = token;
});
ipcRenderer.on('video:metadata', (event, duration)=>{
document.querySelector('#target').innerHTML = `${duration} secs`;
});
// JQuery
$(document).ready(function () {
$("#file-chooser").on('change', function() {
const path = document.querySelector('input').files[0].path;
ipcRenderer.send('video:submit', path);
const fileName = document.querySelector('input').files[0].name
$('.card-title').text(fileName);
$('#transcribe-btn').on('click', function(){
let file = document.querySelector('input').files[0];
let stream = WatsonSpeech.SpeechToText.recognizeFile({
file: file,
token: tokenText,
play: true,
outputElement: '#outputText'
});
stream.on('error', (err)=>{
console.log("error: "+err);
});
})
});
});
</script>
</body>
</html>