Skip to content

Commit 02b6172

Browse files
committed
adding EdgeTTS; removing hit counter
1 parent 79297ad commit 02b6172

4 files changed

Lines changed: 633 additions & 108 deletions

File tree

wiktionary_pron/css/style.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ body.dark_mode button.audio-popup-line:hover {
176176
background-color: #CE93D8;
177177
}
178178

179+
body.dark_mode .audio-popup-selection {
180+
background-color: #CE93D8;
181+
color: white;
182+
border-color: #9C27B0;
183+
}
184+
185+
body.dark_mode .audio-popup-selection:hover {
186+
background-color: #BA68C8;
187+
}
188+
179189

180190
body.dark_mode button {
181191
background-color: #CE93D8;
@@ -326,6 +336,30 @@ body i.icon-moon {
326336
height: 100%;
327337
}
328338

339+
.audio-popup-selection {
340+
position: absolute;
341+
z-index: 1000;
342+
padding: 6px 8px;
343+
background-color: #f0f8ff;
344+
border: 1px solid #ccc;
345+
border-radius: 4px;
346+
font-size: 14px;
347+
cursor: pointer;
348+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
349+
transition: opacity 0.3s ease, background-color 0.2s ease;
350+
opacity: 0;
351+
pointer-events: auto;
352+
}
353+
354+
.audio-popup-selection:hover {
355+
background-color: #e6f3ff;
356+
}
357+
358+
.audio-popup-selection .icon-volume {
359+
margin: 0;
360+
vertical-align: middle;
361+
}
362+
329363
.cell {
330364
position: relative;
331365
display: inline-block;
@@ -354,6 +388,12 @@ body i.icon-moon {
354388

355389
#tts {
356390
max-width: 350px;
391+
min-width: 200px;
392+
}
393+
394+
#tts_switch {
395+
396+
width: 235px;
357397
}
358398

359399
#loading_text:after {

wiktionary_pron/index.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ <h1 style="flex: 1;">Online IPA Converter</h1>
6060

6161

6262
</select>
63+
<!-- <button id="help_button" type="button" title="Help for selected language" style="margin-left: 10px; display: none;">?</button>-->
6364
<p id="loading_text"></p>
6465
</div>
6566
<div>
@@ -79,11 +80,20 @@ <h1 style="flex: 1;">Online IPA Converter</h1>
7980

8081
</select>
8182
<div>
83+
<div>
84+
<span>Voice Engine:</span>
85+
<select autocomplete="off" class="dropdown" disabled="true" id="tts_switch">
86+
<option value="browser" selected>Browser built-in</option>
87+
<option value="edge">Expanded (ms-edge-tts)</option>
88+
</select>
89+
</div>
8290
TTS: <select autocomplete="off" class="dropdown" disabled="true" id="tts">
83-
<option disabled selected value> --</option>
91+
<option disabled selected value> -- select an option --</option>
8492

8593

8694
</select>
95+
96+
8797
<div>
8898
Speed: <input class="custom-input" type="range" min="0" max="200" step="10" value="100" id="tts_speed">
8999
Volume: <input class="custom-input" type="range" min="0" max="100" step="10" value="100"
@@ -203,9 +213,5 @@ <h1 style="flex: 1;">Online IPA Converter</h1>
203213

204214
</div>
205215

206-
<a href="https://hits.seeyoufarm.com" style="display:none;"><img
207-
src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fhellpanderrr.github.io%2Fwiktionary_pron%2Findex.html&count_bg=%23414141&title_bg=%236E2424&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
208-
209-
210216
</body>
211217

wiktionary_pron/scripts/main.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
updateLoadingText,
1515
wait,
1616
} from "./utils.js";
17-
import { tts } from "./tts.js";
17+
import { tts, setLanguageAndFindVoice } from "./tts.js";
1818
import { toPdf } from "./pdf_export.js";
1919
import { toCsv } from "./csv_export.js";
2020
import { loadLexicon } from "./lexicon.js";
@@ -101,7 +101,8 @@ async function transcribe(mode, translate = false, inputText = null) {
101101
lang === "Ukrainian" ||
102102
lang === "Czech" ||
103103
lang === "Russian" ||
104-
lang === "Lituanian"
104+
lang === "Lituanian" ||
105+
lang === "French"
105106
) {
106107
[value, values] = processGermanIpa(value);
107108
}
@@ -179,7 +180,8 @@ async function transcribe(mode, translate = false, inputText = null) {
179180
lang === "Czech" ||
180181
lang === "Lithuanian" ||
181182
lang === "Russian" ||
182-
lang === "Ukrainian"
183+
lang === "Ukrainian" ||
184+
lang === "French"
183185
) {
184186
[value, values] = processGermanIpa(value);
185187
} else {
@@ -313,7 +315,8 @@ async function transcribe(mode, translate = false, inputText = null) {
313315
lang === "Czech" ||
314316
lang === "Ukrainian" ||
315317
lang === "Lituanian" ||
316-
lang === "Russian"
318+
lang === "Russian" ||
319+
lang === "French"
317320
) {
318321
[value, values] = processGermanIpa(results[i]?.value || "");
319322
} else {
@@ -395,7 +398,8 @@ async function transcribe(mode, translate = false, inputText = null) {
395398
lang === "Czech" ||
396399
lang === "Lituanian" ||
397400
lang === "Russian" ||
398-
lang === "Ukrainian"
401+
lang === "Ukrainian" ||
402+
lang === "French"
399403
) {
400404
Array.from(document.querySelectorAll(".ipa")).map((x) => {
401405
if (
@@ -611,6 +615,23 @@ async function updateOptionsUponLanguageSelection(event) {
611615
useDictionary = "true";
612616
}
613617
console.log("changing language to ", selectedLanguage);
618+
619+
// Update help button
620+
const helpButton = document.getElementById("help_button");
621+
if (helpButton) {
622+
if (selectedLanguage && selectedLanguage !== "-- select an option --") {
623+
helpButton.style.display = "inline-block";
624+
helpButton.onclick = () => {
625+
const helpUrl = `help/${selectedLanguage
626+
.toLowerCase()
627+
.replace(/\s+/g, "_")}.html`;
628+
window.open(helpUrl, "_blank");
629+
};
630+
} else {
631+
helpButton.style.display = "none";
632+
}
633+
}
634+
614635
try {
615636
if (urlParams.get("lang") !== selectedLanguage) {
616637
window.history.pushState({}, "", `?lang=${selectedLanguage}`);
@@ -652,7 +673,7 @@ async function updateOptionsUponLanguageSelection(event) {
652673
loadedLanguages[selectedLanguage] = true;
653674
}
654675

655-
selectTTS(lang.ttsCode);
676+
setLanguageAndFindVoice(lang.ttsCode);
656677

657678
function updateSelectOptions(selectedValue, selectElement, options) {
658679
selectElement.innerHTML = "";
@@ -676,17 +697,8 @@ async function updateOptionsUponLanguageSelection(event) {
676697
console.log("Finished changing language to ", selectedLanguage);
677698
await processTextParam();
678699
rememberText();
679-
}
680-
681-
function selectTTS(language) {
682-
const voices = Array.from(document.querySelector("#tts").options);
683-
const relevantVoices = voices.filter((option) =>
684-
(option.getAttribute("data-lang") || "").includes(language),
685-
);
686-
687-
if (relevantVoices.length > 0) {
688-
document.querySelector("#tts").value = relevantVoices[0].value;
689-
}
700+
globalThis.transcriptionLang = selectedLanguage;
701+
globalThis.transcriptionLangCode = lang.ttsCode;
690702
}
691703

692704
const isDarkMode = () => document.body.classList.contains("dark_mode");

0 commit comments

Comments
 (0)