abdullahalioo commited on
Commit
458209e
·
verified ·
1 Parent(s): 3c113a3

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +60 -18
index.html CHANGED
@@ -1,19 +1,61 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </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>Text to Speech</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ text-align: center;
11
+ padding: 20px;
12
+ }
13
+ textarea {
14
+ width: 80%;
15
+ height: 100px;
16
+ margin-bottom: 10px;
17
+ }
18
+ select, button {
19
+ margin: 10px;
20
+ padding: 10px;
21
+ }
22
+ </style>
23
+ </head>
24
+ <body>
25
+ <h1>Text to Speech</h1>
26
+ <textarea id="text" placeholder="Enter text to speak..."></textarea>
27
+ <br>
28
+ <select id="voiceSelect"></select>
29
+ <br>
30
+ <button onclick="speak()">Speak</button>
31
+
32
+ <script>
33
+ const synth = window.speechSynthesis;
34
+ const voiceSelect = document.getElementById('voiceSelect');
35
+
36
+ function loadVoices() {
37
+ const voices = synth.getVoices();
38
+ voiceSelect.innerHTML = '';
39
+ voices.forEach(voice => {
40
+ const option = document.createElement('option');
41
+ option.value = voice.name;
42
+ option.textContent = `${voice.name} (${voice.lang})`;
43
+ voiceSelect.appendChild(option);
44
+ });
45
+ }
46
+
47
+ function speak() {
48
+ const text = document.getElementById('text').value;
49
+ const utterance = new SpeechSynthesisUtterance(text);
50
+ const selectedVoice = voiceSelect.value;
51
+ utterance.voice = synth.getVoices().find(voice => voice.name === selectedVoice);
52
+ synth.speak(utterance);
53
+ }
54
+
55
+ loadVoices();
56
+ if (speechSynthesis.onvoiceschanged !== undefined) {
57
+ speechSynthesis.onvoiceschanged = loadVoices;
58
+ }
59
+ </script>
60
+ </body>
61
  </html>