File size: 1,458 Bytes
134b6b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html>
    <head>
        <title>Text-to-Speech</title>
    </head>
    <body>
        <h1>Text-to-Speech Conversion</h1>
        <form action="/convert" method="post">
            <textarea name="text" rows="5" cols="50" placeholder="Enter text here"></textarea><br>
            <select name="voice">
                <option value="">Select Voice</option>
                <!-- Options will be populated dynamically -->
            </select><br>
            <label for="rate">Speech Rate Adjustment (%):</label>
            <input type="range" id="rate" name="rate" min="-50" max="50" value="0"><br>
            <label for="pitch">Pitch Adjustment (Hz):</label>
            <input type="range" id="pitch" name="pitch" min="-20" max="20" value="0"><br>
            <input type="submit" value="Convert">
        </form>
        <script>
            async function populateVoices() {
                const response = await fetch('/voices');
                const voices = await response.json();
                const select = document.querySelector('select[name="voice"]');
                for (const [key, value] of Object.entries(voices)) {
                    const option = document.createElement('option');
                    option.value = key;
                    option.textContent = key;
                    select.appendChild(option);
                }
            }
            populateVoices();
        </script>
    </body>
</html>