diff --git a/inbox.py b/inbox.py index 0e19e01c2..6559db0ac 100644 --- a/inbox.py +++ b/inbox.py @@ -83,6 +83,7 @@ from categories import guessHashtagCategory from context import hasValidContext from content import htmlReplaceQuoteMarks from speaker import speakerReplaceLinks +from speaker import speakerPronounce def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None: @@ -2168,6 +2169,7 @@ def _updateSpeaker(baseDir: str, nickname: str, domain: str, content = html.unescape(content) content = removeHtml(htmlReplaceQuoteMarks(content)) content = speakerReplaceLinks(content, translate, detectedLinks) + content = speakerPronounce(baseDir, content, translate) imageDescription = '' if postJsonObject['object'].get('attachment'): diff --git a/speaker.py b/speaker.py index ff50c6af3..029062476 100644 --- a/speaker.py +++ b/speaker.py @@ -6,6 +6,7 @@ __maintainer__ = "Bob Mottram" __email__ = "bob@freedombone.net" __status__ = "Production" +import os import random from auth import createBasicAuthHeader from session import getJson @@ -33,6 +34,48 @@ def getSpeakerRange(displayName: str) -> int: return random.randint(300, 800) +def speakerPronounce(baseDir: str, sayText: str, translate: {}) -> str: + """Screen readers may not always pronounce correctly, so you + can have a file which specifies conversions. File should contain + line items such as: + Epicyon -> Epi-cyon + """ + pronounceFilename = baseDir + '/accounts/speaker_pronounce.txt' + convertDict = { + "Epicyon": "Epi-cyon", + "espeak": "e-speak", + "#": translate["hashtag"], + ":)": translate["smile"], + ";)": translate["wink"], + ":-)": translate["smile"], + ";-)": translate["wink"], + "*": "" + } + if os.path.isfile(pronounceFilename): + with open(pronounceFilename, 'r') as fp: + pronounceList = fp.readlines() + for conversion in pronounceList: + separator = None + if '->' in conversion: + separator = '->' + elif ';' in conversion: + separator = ';' + elif ':' in conversion: + separator = ':' + elif ',' in conversion: + separator = ',' + if not separator: + continue + + text = conversion.split(separator)[0].strip() + converted = conversion.split(separator)[1].strip() + convertDict[text] = converted + for text, converted in convertDict.items(): + if text in sayText: + sayText = sayText.replace(text, converted) + return sayText + + def speakerReplaceLinks(sayText: str, translate: {}, detectedLinks: []) -> str: """Replaces any links in the given text with "link to [domain]". diff --git a/translations/ar.json b/translations/ar.json index 362cafdc9..437ae04f4 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -374,5 +374,8 @@ "DM bounce": "يتم قبول الرسائل فقط من الحسابات المتبعة", "Next": "التالي", "Preview": "معاينة", - "Linked": "رابط موقع" + "Linked": "رابط موقع", + "hashtag": "رابطة هاشتاق", + "smile": "ابتسامة", + "wink": "غمزة" } diff --git a/translations/ca.json b/translations/ca.json index 31a088dd2..b89e4ae86 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -374,5 +374,8 @@ "DM bounce": "Els missatges només s’accepten des dels comptes seguits", "Next": "Pròxim", "Preview": "Vista prèvia", - "Linked": "enllaç web" + "Linked": "enllaç web", + "hashtag": "etiqueta", + "smile": "somriure", + "wink": "fer l'ullet" } diff --git a/translations/cy.json b/translations/cy.json index a7dea2397..c9b3c9948 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -374,5 +374,8 @@ "DM bounce": "Dim ond o gyfrifon a ddilynir y derbynnir negeseuon", "Next": "Nesaf", "Preview": "Rhagolwg", - "Linked": "Dolen we" + "Linked": "Dolen we", + "hashtag": "hash-nod", + "smile": "gwenu", + "wink": "winc" } diff --git a/translations/de.json b/translations/de.json index b6514707b..b82173280 100644 --- a/translations/de.json +++ b/translations/de.json @@ -374,5 +374,8 @@ "DM bounce": "Nachrichten werden nur von folgenden Konten akzeptiert", "Next": "Nächster", "Preview": "Vorschau", - "Linked": "Weblink" + "Linked": "Weblink", + "hashtag": "hash-tag", + "smile": "Lächeln", + "wink": "zwinkern" } diff --git a/translations/en.json b/translations/en.json index 39d21a55a..432484090 100644 --- a/translations/en.json +++ b/translations/en.json @@ -374,5 +374,8 @@ "DM bounce": "Messages are only accepted from followed accounts", "Next": "Next", "Preview": "Preview", - "Linked": "Web linked" + "Linked": "Web linked", + "hashtag": "hash-tag", + "smile": "smile", + "wink": "wink" } diff --git a/translations/es.json b/translations/es.json index 0170be798..5bb19751d 100644 --- a/translations/es.json +++ b/translations/es.json @@ -374,5 +374,8 @@ "DM bounce": "Solo se aceptan mensajes de cuentas seguidas", "Next": "Próxima", "Preview": "Avance", - "Linked": "enlace web" + "Linked": "enlace web", + "hashtag": "hash-tag", + "smile": "sonreír", + "wink": "guiño" } diff --git a/translations/fr.json b/translations/fr.json index 68887c1a5..c941a8501 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -374,5 +374,8 @@ "DM bounce": "Les messages ne sont acceptés que des comptes suivis", "Next": "Suivante", "Preview": "Aperçu", - "Linked": "lien Web" + "Linked": "lien Web", + "hashtag": "hash-tag", + "smile": "le sourire", + "wink": "clin d'œil" } diff --git a/translations/ga.json b/translations/ga.json index a9ff8814c..532f88b43 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -374,5 +374,8 @@ "DM bounce": "Ní ghlactar le teachtaireachtaí ach ó chuntais a leanann", "Next": "Ar Aghaidh", "Preview": "Réamhamharc", - "Linked": "Nasc gréasáin" + "Linked": "Nasc gréasáin", + "hashtag": "hash-tag", + "smile": "aoibh gháire", + "wink": "wink" } diff --git a/translations/hi.json b/translations/hi.json index ae79a7f7e..849a6dd1a 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -374,5 +374,8 @@ "DM bounce": "संदेश केवल अनुसरण किए गए खातों से स्वीकार किए जाते हैं", "Next": "अगला", "Preview": "पूर्वावलोकन", - "Linked": "वेब लिंक" + "Linked": "वेब लिंक", + "hashtag": "हैशटैग", + "smile": "मुस्कुराओ", + "wink": "आँख मारना" } diff --git a/translations/it.json b/translations/it.json index 1ee936313..eae56d560 100644 --- a/translations/it.json +++ b/translations/it.json @@ -374,5 +374,8 @@ "DM bounce": "I messaggi sono accettati solo dagli account seguiti", "Next": "Il prossimo", "Preview": "Anteprima", - "Linked": "collegamento web" + "Linked": "collegamento web", + "hashtag": "hash-tag", + "smile": "Sorridi", + "wink": "occhiolino" } diff --git a/translations/ja.json b/translations/ja.json index 14d2e1b25..39d70d3d2 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -374,5 +374,8 @@ "DM bounce": "メッセージはフォローされているアカウントからのみ受け付けられます", "Next": "次", "Preview": "プレビュー", - "Linked": "ウェブリンク" + "Linked": "ウェブリンク", + "hashtag": "ハッシュタグ", + "smile": "スマイル", + "wink": "ウィンク" } diff --git a/translations/oc.json b/translations/oc.json index f40e42213..beaced8cf 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -370,5 +370,8 @@ "DM bounce": "Messages are only accepted from followed accounts", "Next": "Next", "Preview": "Preview", - "Linked": "Web link" + "Linked": "Web link", + "hashtag": "hash-tag", + "smile": "smile", + "wink": "wink" } diff --git a/translations/pt.json b/translations/pt.json index 7b5251016..ee8516a08 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -374,5 +374,8 @@ "DM bounce": "Mensagens são aceitas apenas de contas seguidas", "Next": "Próxima", "Preview": "Antevisão", - "Linked": "link da web" + "Linked": "link da web", + "hashtag": "hash-tag", + "smile": "sorrir", + "wink": "piscar" } diff --git a/translations/ru.json b/translations/ru.json index 4273fe15a..305595f78 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -374,5 +374,8 @@ "DM bounce": "Сообщения принимаются только от следующих аккаунтов", "Next": "Следующий", "Preview": "Предварительный просмотр", - "Linked": "интернет-ссылка" + "Linked": "интернет-ссылка", + "hashtag": "хэштег", + "smile": "улыбка", + "wink": "подмигивание" } diff --git a/translations/zh.json b/translations/zh.json index 18cacf995..703a28232 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -374,5 +374,8 @@ "DM bounce": "仅接受来自后续帐户的邮件", "Next": "下一个", "Preview": "预览", - "Linked": "网页链接" + "Linked": "网页链接", + "hashtag": "井号", + "smile": "微笑", + "wink": "眨眼" }