Add ability to copy voice key to clipboard

This commit is contained in:
Michael Hansen 2022-05-10 13:50:35 -04:00
commit 2eafdbaa63

View file

@ -101,6 +101,9 @@
<select id="speaker-list" name="speaker"> <select id="speaker-list" name="speaker">
</select> </select>
</div> </div>
<div class="col">
<button id="copy-voice" class="btn btn-info btn-sm" title="Copy voice key to clipboard">Copy</button>
</div>
</div> </div>
<div id="audio-message" class="row mt-3" hidden> <div id="audio-message" class="row mt-3" hidden>
<div class="col"> <div class="col">
@ -430,12 +433,26 @@
}) })
} }
function copyVoiceKey() {
var voiceName = q('#voice-name')
var speakerList = q('#speaker-list')
var voiceKey = voiceName.options[voiceName.selectedIndex].value
if (speakerList.options.length > 1) {
voiceKey += '#' + speakerList.options[speakerList.selectedIndex].value
}
navigator.clipboard.writeText(voiceKey)
}
window.addEventListener('load', function() { window.addEventListener('load', function() {
loadVoices() loadVoices()
q('#voice-language').addEventListener('change', langChanged) q('#voice-language').addEventListener('change', langChanged)
q('#voice-name').addEventListener('change', nameChanged) q('#voice-name').addEventListener('change', nameChanged)
q('#copy-voice').addEventListener('click', copyVoiceKey)
}) })
</script> </script>