Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1021148 // dm_sayWithAutoLanguage_splitAtQuotes - use different languages for different parts

JavaX fragment (include)

svoid dm_sayWithAutoLanguage_splitAtQuotes(S s) {
  LS parts = nempties(splitAt(s, "\""));
  LS languages = replaceNullsWith('en, map dm_detectGermanVsEnglish(parts));
  int i = 0;
  while (i < l(parts)) {
    int j = i;
    S lang = languages.get(i);
    while (j+1 < l(parts) && eq(lang, languages.get(j+1))) ++j;
    S part = joinWithSpace(subList(parts, i, j+1));
    if (containsLetterOrDigit(part))
      if (eq(lang, 'de)) dm_sayInGerman(part); else dm_sayInEnglish(part);
    i = j+1;
  }
}

Author comment

Began life as a copy of #1021145

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: #1021148
Snippet name: dm_sayWithAutoLanguage_splitAtQuotes - use different languages for different parts
Eternal ID of this version: #1021148/2
Text MD5: e083aaf6c8256862991c054bf04605af
Author: stefan
Category: javax / speech
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-23 23:48:58
Source code size: 511 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 286 / 332
Version history: 1 change(s)
Referenced in: [show references]