File size: 2,560 Bytes
64ada0a
d4c15b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7218922
d4c15b2
7218922
 
 
d4c15b2
4356c14
d4c15b2
 
 
 
 
 
4356c14
d4c15b2
 
 
 
 
 
 
 
 
 
 
 
4356c14
d4c15b2
 
 
 
 
 
 
 
4356c14
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
97
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Speech Recognition Landing Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
        }

        header {
            background-color: #333;
            color: #fff;
            padding: 20px;
            text-align: center;
        }

        h1 {
            font-size: 36px;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }

        #output {
            background-color: #fff;
            border: 1px solid #ccc;
            padding: 10px;
            margin-top: 20px;
            min-height: 150px;
        }

        #output p {
            margin: 0;
        }

        #speechButton {
            background-color: #0073e6;
            color: #fff;
            padding: 10px 20px;
            border: none;
            cursor: pointer;
            font-size: 18px;
        }

        #speechButton:hover {
            background-color: #005bb7;
        }
    </style>
</head>
<body>
    <header>
        <h1>Speech Recognition Landing Page</h1>
    </header>
   <div class="container">
        <h2>Speech to Text</h2>
        <form id="recordingForm" action="/start-recording" method="POST">
            <button type="submit" id="speechButton">Start Recording</button>
        </form>
        <div id="output">
            <p id="transcription">Transcription will appear here...</p>
        </div>
    </div>

    <script>
        const speechButton = document.getElementById('speechButton');
        const output = document.getElementById('output');
        const transcription = document.getElementById('transcription');
        const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();

        recognition.lang = 'en-US';

        speechButton.addEventListener('click', () => {
            recognition.start();
            speechButton.disabled = true;
            speechButton.innerText = 'Recording...';
        });

        recognition.onresult = (event) => {
            const transcript = event.results[0][0].transcript;
            transcription.textContent = transcript;
        };

        recognition.onend = () => {
            speechButton.disabled = false;
            speechButton.innerText = 'Start Recording';
        };
    </script>
</body>
</html>