Uses 911K of libraries. Click here for Pure Java version (9080L/48K).
!7 cmodule SayWithLanguageDetect { S typingText, text, detectedLanguage; visualize { ret northCenterAndSouthWithMargins( dm_bigInputAndSubmit('typingText, "Say / Sag", rThread sayIt), fontSizePlus(5, dm_centeredLabel('detectedLanguage)), rightAlignedButtons("Correct", rThread correct, "Not correct", rThread notCorrect); } void sayIt enter { S s = typingText; setField(text := s); S lang = dm_detectGermanVsEnglish(s); print(s + " => " + lang); if (eq("de", lang)) { setField(detectedLanguage := "Detected as: German"); dm_sayInGerman(s); ret; } if (eq("en", lang)) setField(detectedLanguage := "Detected as: English"); else setField(detectedLanguage := "Unknown language"); dm_sayInEnglish(s); } void correct enter { if (!swic(detectedLanguage, "unknown")) dm_addWordToLanguageExample(text, lower(lastWord(detectedLanguage))); } void notCorrect enter { fS text = this.text; inputText("What is the correct language for " + quote(text) + "?", cic(detectedLanguage, "english") ? "german" : "english", voidfunc(S s) { dm_addWordToLanguageExample(text, lower(s)); }); } // API void say(S s) { setField(typingText := s); sayIt(); } }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021138 |
Snippet name: | Say With Language Auto-Detect |
Eternal ID of this version: | #1021138/10 |
Text MD5: | 42c25ce52a8c76c3c5817e1cfcf0e42d |
Transpilation MD5: | 831529a5f0c2c2f531d0d2d265e4df55 |
Author: | stefan |
Category: | javax / speech |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-23 23:36:07 |
Source code size: | 1352 bytes / 49 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 320 / 926 |
Version history: | 9 change(s) |
Referenced in: | #1021145 - dm_sayWithAutoLanguage |