-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp5.html
45 lines (41 loc) · 1.15 KB
/
temp5.html
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
<!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">
<title>STT</title>
</head>
<body>
<!-- <a id="download">Download</a>
<button id="stop">Stop</button> -->
<script>
navigator.mediaDevices.getUserMedia({ audio: true })
.then(stream => {
const mediaRecorder = new MediaRecorder(stream);
mediaRecorder.start();
const audioChunks = [];
mediaRecorder.addEventListener("dataavailable", event => {
audioChunks.push(event.data);
});
mediaRecorder.addEventListener("stop", () => {
const audioBlob = new Blob(audioChunks, { 'type' : 'audio/wav' });
const audioUrl = URL.createObjectURL(audioBlob);
const audio = new Audio(audioUrl);
$.post("/stt", {
body: audioBlob
}, function(data, status) {
if(status == success) {
console.log("Success")
}
})
// console.log(audio)
// audio.play();
});
setTimeout(() => {
mediaRecorder.stop();
}, 5000);
});
</script>
</body>
</html>