Spaces:
Running
Running
Update templates/interface.html
Browse files- templates/interface.html +26 -14
templates/interface.html
CHANGED
@@ -94,30 +94,42 @@
|
|
94 |
</script>
|
95 |
|
96 |
</form>
|
97 |
-
<script>
|
98 |
-
const
|
99 |
-
const
|
100 |
|
101 |
-
|
102 |
-
|
|
|
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 |
-
|
109 |
-
|
|
|
|
|
110 |
|
111 |
-
|
112 |
-
|
|
|
113 |
option.value = speakerId;
|
114 |
option.textContent = speakerName;
|
115 |
-
|
116 |
}
|
117 |
})
|
118 |
-
.catch(error =>
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
<!-- Move the JavaScript code outside the conditional block -->
|
122 |
|
123 |
</body>
|
|
|
94 |
</script>
|
95 |
|
96 |
</form>
|
97 |
+
<script>
|
98 |
+
const modelSelect = document.getElementById('selected_model');
|
99 |
+
const speakerSelect = document.getElementById('selected_speaker_id');
|
100 |
|
101 |
+
// Function to load speaker options based on the selected model
|
102 |
+
function loadSpeakers() {
|
103 |
+
const selectedModel = modelSelect.value;
|
104 |
|
105 |
+
// Fetch the speaker options for the selected model from the server
|
106 |
fetch(`/get_speaker_id_map?selected_model=${selectedModel}`)
|
107 |
.then(response => response.json())
|
108 |
.then(data => {
|
109 |
+
// Clear existing options
|
110 |
+
while (speakerSelect.firstChild) {
|
111 |
+
speakerSelect.removeChild(speakerSelect.firstChild);
|
112 |
+
}
|
113 |
|
114 |
+
// Populate the speaker options based on data received
|
115 |
+
for (const [speakerId, speakerName] of Object.entries(data.speaker_id_map)) {
|
116 |
+
const option = document.createElement('option');
|
117 |
option.value = speakerId;
|
118 |
option.textContent = speakerName;
|
119 |
+
speakerSelect.appendChild(option);
|
120 |
}
|
121 |
})
|
122 |
+
.catch(error => {
|
123 |
+
console.error('Error fetching speaker options:', error);
|
124 |
+
});
|
125 |
+
}
|
126 |
+
|
127 |
+
// Add an event listener to load speakers when the model selection changes
|
128 |
+
modelSelect.addEventListener('change', loadSpeakers);
|
129 |
+
|
130 |
+
// Initialize the speaker options based on the default selected model
|
131 |
+
loadSpeakers();
|
132 |
+
</script>
|
133 |
<!-- Move the JavaScript code outside the conditional block -->
|
134 |
|
135 |
</body>
|