Pipertts / templates /interface.html
Gregniuki's picture
Update templates/interface.html
638e425
raw
history blame
4.57 kB
<!DOCTYPE html>
<html>
<head>
<title>Fast TTS</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/styles.css"> <!-- Link to your external CSS file -->
<!-- Add any CSS links or styles here -->
</head>
<body>
<form method="post" action="/" onsubmit="showLoadingMessage()">
<div>
<label for="text_input">Text to synthesize:</label>
<textarea id="text_input" name="text_input" rows="5" cols="50">{{ text_input }}</textarea>
</div>
<div>
<label for="selection">Select speaker:</label>
<select id="speaker" name="speaker">
{% for option in data.speaker_options %}
<option {% if option == data.default_speaker %}selected{% endif %}>{{ option }}</option>
{% endfor %}
</select>
</div>
<div>
<label for="selected_model">Select a model:</label>
<select id="selected_model" name="selected_model">
{% for model_name in model_names %}
<option {% if model_name == selected_model %}selected{% endif %}>{{ model_name }}</option>
{% endfor %}
</select>
</div>
<div>
<label for="speaker_select">Select a speaker:</label>
<!-- Your existing select element for choosing a speaker -->
<select id="speaker_select" name="speaker_select">
{% for speaker_id, speaker_name in speaker_id_map.items() %}
<option value="{{ speaker_id }}">{{ speaker_name }}</option>
{% endfor %}
</select>
</div>
<div id="speaker_selection" style="display: none;">
<!-- Dropdown for speaker selection -->
</div>
<div>
<label for="speed_slider">Rate scale:</label>
<input type="range" id="speed_slider" name="speed_slider" min="0.25" max="2" step="0.1" value="1">
</div>
<div>
<label for="noise_scale_slider">Phoneme noise scale:</label>
<input type="range" id="noise_scale_slider" name="noise_scale_slider" min="0.25" max="1" step="0.1" value="0.667">
</div>
<div>
<label for="noise_scale_w_slider">Phoneme stressing scale:</label>
<input type="range" id="noise_scale_w_slider" name="noise_scale_w_slider" min="0.25" max="1" step="0.1" value="1">
</div>
<!-- Add a div with the "loading-message" ID for the loading message -->
<div id="loading-message"></div>
<!-- Include the dynamic content from response_html -->
{{ response_html|safe }}
<div>
<button type="submit" id="synthesize_button">Synthesize</button>
</div>
<!-- Your script to fetch and populate the select element -->
<script>
// Add an event listener to load the speaker_id_map when the page loads
window.addEventListener("load", function() {
// Fetch the speaker_id_map from the server
fetch("/get_speaker_id_map")
.then(response => response.json())
.then(data => {
// Get a reference to the existing select element
var speakerSelect = document.getElementById("speaker_select");
// Remove existing options (if any) from the select element
while (speakerSelect.firstChild) {
speakerSelect.removeChild(speakerSelect.firstChild);
}
// Populate the select element with speaker names
for (var speakerId in data.speaker_id_map) {
var option = document.createElement("option");
option.value = speakerId;
option.textContent = data.speaker_id_map[speakerId];
speakerSelect.appendChild(option);
}
});
});
</script>
{% if file_url %}
<h2>Generated Audio</h2>
<audio controls id="audio-player">
<source src="{{ file_url }}" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<a href="{{ file_url }}" download>Download Audio</a>
{% endif %}
<script>
function showLoadingMessage() {
// Display the loading message
document.getElementById("loading-message").innerText = "Generating your audio, please wait...";
// Optionally, you can disable the form elements to prevent further interactions while waiting
document.getElementById("synthesize_button").disabled = true;
}
</script>
</form>
<!-- Move the JavaScript code outside the conditional block -->
</body>
</html>