krishna195 commited on
Commit
6f89e0d
·
verified ·
1 Parent(s): 0f90ec3

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +23 -0
script.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function transcribe() {
2
+ let fileInput = document.getElementById('audioInput').files[0];
3
+ if (!fileInput) {
4
+ alert("Please upload an audio file");
5
+ return;
6
+ }
7
+
8
+ let reader = new FileReader();
9
+ reader.readAsDataURL(fileInput);
10
+ reader.onload = async function () {
11
+ let audioURL = reader.result;
12
+
13
+ // Load the Whisper model
14
+ let transcriber = await window.Transformers.pipeline(
15
+ 'automatic-speech-recognition',
16
+ 'Xenova/whisper-tiny.en'
17
+ );
18
+
19
+ // Perform transcription
20
+ let output = await transcriber(audioURL);
21
+ document.getElementById('output').innerText = output.text;
22
+ };
23
+ }