Spaces:
Build error
Build error
Update templates/interface.html
Browse files- templates/interface.html +39 -41
templates/interface.html
CHANGED
|
@@ -25,25 +25,25 @@
|
|
| 25 |
</select>
|
| 26 |
|
| 27 |
</div>
|
|
|
|
| 28 |
<div>
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
</div>
|
| 36 |
|
|
|
|
| 37 |
<div>
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
</select>
|
| 45 |
</div>
|
| 46 |
-
|
| 47 |
<div id="speaker_selection" style="display: none;">
|
| 48 |
<!-- Dropdown for speaker selection -->
|
| 49 |
</div>
|
|
@@ -72,32 +72,7 @@
|
|
| 72 |
<div>
|
| 73 |
<button type="submit" id="synthesize_button">Synthesize</button>
|
| 74 |
</div>
|
| 75 |
-
|
| 76 |
-
<script>
|
| 77 |
-
// Add an event listener to load the speaker_id_map when the page loads
|
| 78 |
-
window.addEventListener("load", function() {
|
| 79 |
-
// Fetch the speaker_id_map from the server
|
| 80 |
-
fetch("/get_speaker_id_map")
|
| 81 |
-
.then(response => response.json())
|
| 82 |
-
.then(data => {
|
| 83 |
-
// Get a reference to the existing select element
|
| 84 |
-
var speakerSelect = document.getElementById("speaker_select");
|
| 85 |
-
|
| 86 |
-
// Remove existing options (if any) from the select element
|
| 87 |
-
while (speakerSelect.firstChild) {
|
| 88 |
-
speakerSelect.removeChild(speakerSelect.firstChild);
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
// Populate the select element with speaker names
|
| 92 |
-
for (var speakerId in data.speaker_id_map) {
|
| 93 |
-
var option = document.createElement("option");
|
| 94 |
-
option.value = speakerId;
|
| 95 |
-
option.textContent = data.speaker_id_map[speakerId];
|
| 96 |
-
speakerSelect.appendChild(option);
|
| 97 |
-
}
|
| 98 |
-
});
|
| 99 |
-
});
|
| 100 |
-
</script>
|
| 101 |
|
| 102 |
{% if file_url %}
|
| 103 |
<h2>Generated Audio</h2>
|
|
@@ -119,7 +94,30 @@
|
|
| 119 |
</script>
|
| 120 |
|
| 121 |
</form>
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
<!-- Move the JavaScript code outside the conditional block -->
|
| 124 |
|
| 125 |
</body>
|
|
|
|
| 25 |
</select>
|
| 26 |
|
| 27 |
</div>
|
| 28 |
+
<!-- Select a model -->
|
| 29 |
<div>
|
| 30 |
+
<label for="selected_model">Select a model:</label>
|
| 31 |
+
<select id="selected_model" name="selected_model">
|
| 32 |
+
{% for model_name in onnx_models %}
|
| 33 |
+
<option value="{{ model_name }}">{{ model_name }}</option>
|
| 34 |
+
{% endfor %}
|
| 35 |
+
</select>
|
| 36 |
</div>
|
| 37 |
|
| 38 |
+
<!-- Display speaker options -->
|
| 39 |
<div>
|
| 40 |
+
<label for="selected_speaker_id">Select a speaker:</label>
|
| 41 |
+
<select id="selected_speaker_id" name="selected_speaker_id">
|
| 42 |
+
{% for speaker_id, speaker_name in speaker_id_map.items() %}
|
| 43 |
+
<option value="{{ speaker_id }}">{{ speaker_name }}</option>
|
| 44 |
+
{% endfor %}
|
| 45 |
+
</select>
|
|
|
|
| 46 |
</div>
|
|
|
|
| 47 |
<div id="speaker_selection" style="display: none;">
|
| 48 |
<!-- Dropdown for speaker selection -->
|
| 49 |
</div>
|
|
|
|
| 72 |
<div>
|
| 73 |
<button type="submit" id="synthesize_button">Synthesize</button>
|
| 74 |
</div>
|
| 75 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
{% if file_url %}
|
| 78 |
<h2>Generated Audio</h2>
|
|
|
|
| 94 |
</script>
|
| 95 |
|
| 96 |
</form>
|
| 97 |
+
<script>
|
| 98 |
+
const selectedModelDropdown = document.getElementById("selected_model");
|
| 99 |
+
const speakerDropdown = document.getElementById("selected_speaker_id");
|
| 100 |
+
|
| 101 |
+
selectedModelDropdown.addEventListener("change", () => {
|
| 102 |
+
const selectedModel = selectedModelDropdown.value;
|
| 103 |
+
|
| 104 |
+
// Fetch speaker options for the selected model
|
| 105 |
+
fetch(`/get_speaker_id_map?selected_model=${selectedModel}`)
|
| 106 |
+
.then(response => response.json())
|
| 107 |
+
.then(data => {
|
| 108 |
+
const speakerIdMap = data.speaker_id_map;
|
| 109 |
+
speakerDropdown.innerHTML = ""; // Clear existing options
|
| 110 |
+
|
| 111 |
+
for (const [speakerId, speakerName] of Object.entries(speakerIdMap)) {
|
| 112 |
+
const option = document.createElement("option");
|
| 113 |
+
option.value = speakerId;
|
| 114 |
+
option.textContent = speakerName;
|
| 115 |
+
speakerDropdown.appendChild(option);
|
| 116 |
+
}
|
| 117 |
+
})
|
| 118 |
+
.catch(error => console.error("Error fetching speaker options:", error));
|
| 119 |
+
});
|
| 120 |
+
</script>
|
| 121 |
<!-- Move the JavaScript code outside the conditional block -->
|
| 122 |
|
| 123 |
</body>
|