awacke1 commited on
Commit
037a825
·
verified ·
1 Parent(s): 9dc594c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +11 -122
index.html CHANGED
@@ -1,125 +1,14 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Simple ASR Client</title>
7
- <script type="importmap">
8
- {
9
- "imports": {
10
- "@xenova/transformers": "https://cdn.jsdelivr.net/npm/@xenova/[email protected]/+esm"
11
- }
12
- }
13
- </script>
14
- <style>
15
- body {
16
- font-family: Arial, sans-serif;
17
- max-width: 800px;
18
- margin: 20px auto;
19
- padding: 20px;
20
- }
21
- #output {
22
- margin-top: 20px;
23
- padding: 10px;
24
- border: 1px solid #ccc;
25
- min-height: 100px;
26
- }
27
- .ready {
28
- color: green;
29
- font-weight: bold;
30
- }
31
- .loading {
32
- color: orange;
33
- }
34
- .error {
35
- color: red;
36
- }
37
- </style>
38
- </head>
39
- <body>
40
- <h1>Simple Speech Recognition</h1>
41
- <div id="status" class="loading">Loading model...</div>
42
- <button id="startBtn" disabled>Start Recording</button>
43
- <div id="output"></div>
44
-
45
- <script type="module">
46
- import { pipeline } from '@xenova/transformers';
47
-
48
- let isRecording = false;
49
- let mediaRecorder = null;
50
- let audioChunks = [];
51
-
52
- const statusElement = document.getElementById('status');
53
- const startBtn = document.getElementById('startBtn');
54
- const output = document.getElementById('output');
55
-
56
- // Initialize the model
57
- async function initModel() {
58
- try {
59
- console.log('Starting model loading...');
60
- statusElement.textContent = 'Loading model...';
61
- statusElement.className = 'loading';
62
-
63
- const model = await pipeline('automatic-speech-recognition', 'Xenova/whisper-tiny');
64
-
65
- console.log('Model loaded successfully!');
66
- statusElement.textContent = 'MODEL LOADED SUCCESSFULLY! Ready to record.';
67
- statusElement.className = 'ready';
68
- startBtn.disabled = false;
69
-
70
- startBtn.onclick = async () => {
71
- if (!isRecording) {
72
- try {
73
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
74
- mediaRecorder = new MediaRecorder(stream);
75
- audioChunks = [];
76
-
77
- mediaRecorder.ondataavailable = (event) => {
78
- audioChunks.push(event.data);
79
- };
80
-
81
- mediaRecorder.onstop = async () => {
82
- const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
83
- try {
84
- const result = await model(audioBlob);
85
- output.textContent += result.text + ' ';
86
- } catch (e) {
87
- console.error('Transcription error:', e);
88
- statusElement.textContent = 'Error during transcription';
89
- statusElement.className = 'error';
90
- }
91
- audioChunks = [];
92
- };
93
-
94
- mediaRecorder.start(1000);
95
- isRecording = true;
96
- startBtn.textContent = 'Stop Recording';
97
- statusElement.textContent = 'Recording...';
98
- statusElement.className = 'loading';
99
- } catch (e) {
100
- console.error('Recording error:', e);
101
- statusElement.textContent = 'Error accessing microphone';
102
- statusElement.className = 'error';
103
- }
104
- } else {
105
- mediaRecorder.stop();
106
- mediaRecorder.stream.getTracks().forEach(track => track.stop());
107
- isRecording = false;
108
- startBtn.textContent = 'Start Recording';
109
- statusElement.textContent = 'Processing...';
110
- statusElement.className = 'loading';
111
- }
112
- };
113
-
114
- } catch (e) {
115
- console.error('Model loading error:', e);
116
- statusElement.textContent = 'Error loading model: ' + e.message;
117
- statusElement.className = 'error';
118
- }
119
- }
120
-
121
- // Start loading the model
122
- initModel();
123
- </script>
124
- </body>
125
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Whisper Web</title>
7
+ <script type="module" crossorigin src="index-47e1f68a.js"></script>
8
+ <link rel="stylesheet" href="/assets/index-9018b2d2.css">
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+
13
+ </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  </html>