mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			TTS custom pronounce
							parent
							
								
									2b26b09980
								
							
						
					
					
						commit
						32e5f03948
					
				
							
								
								
									
										2
									
								
								inbox.py
								
								
								
								
							
							
						
						
									
										2
									
								
								inbox.py
								
								
								
								
							|  | @ -83,6 +83,7 @@ from categories import guessHashtagCategory | ||||||
| from context import hasValidContext | from context import hasValidContext | ||||||
| from content import htmlReplaceQuoteMarks | from content import htmlReplaceQuoteMarks | ||||||
| from speaker import speakerReplaceLinks | from speaker import speakerReplaceLinks | ||||||
|  | from speaker import speakerPronounce | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None: | 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 = html.unescape(content) | ||||||
|     content = removeHtml(htmlReplaceQuoteMarks(content)) |     content = removeHtml(htmlReplaceQuoteMarks(content)) | ||||||
|     content = speakerReplaceLinks(content, translate, detectedLinks) |     content = speakerReplaceLinks(content, translate, detectedLinks) | ||||||
|  |     content = speakerPronounce(baseDir, content, translate) | ||||||
| 
 | 
 | ||||||
|     imageDescription = '' |     imageDescription = '' | ||||||
|     if postJsonObject['object'].get('attachment'): |     if postJsonObject['object'].get('attachment'): | ||||||
|  |  | ||||||
							
								
								
									
										43
									
								
								speaker.py
								
								
								
								
							
							
						
						
									
										43
									
								
								speaker.py
								
								
								
								
							|  | @ -6,6 +6,7 @@ __maintainer__ = "Bob Mottram" | ||||||
| __email__ = "bob@freedombone.net" | __email__ = "bob@freedombone.net" | ||||||
| __status__ = "Production" | __status__ = "Production" | ||||||
| 
 | 
 | ||||||
|  | import os | ||||||
| import random | import random | ||||||
| from auth import createBasicAuthHeader | from auth import createBasicAuthHeader | ||||||
| from session import getJson | from session import getJson | ||||||
|  | @ -33,6 +34,48 @@ def getSpeakerRange(displayName: str) -> int: | ||||||
|     return random.randint(300, 800) |     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: {}, | def speakerReplaceLinks(sayText: str, translate: {}, | ||||||
|                         detectedLinks: []) -> str: |                         detectedLinks: []) -> str: | ||||||
|     """Replaces any links in the given text with "link to [domain]". |     """Replaces any links in the given text with "link to [domain]". | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "يتم قبول الرسائل فقط من الحسابات المتبعة", |     "DM bounce": "يتم قبول الرسائل فقط من الحسابات المتبعة", | ||||||
|     "Next": "التالي", |     "Next": "التالي", | ||||||
|     "Preview": "معاينة", |     "Preview": "معاينة", | ||||||
|     "Linked": "رابط موقع" |     "Linked": "رابط موقع", | ||||||
|  |     "hashtag": "رابطة هاشتاق", | ||||||
|  |     "smile": "ابتسامة", | ||||||
|  |     "wink": "غمزة" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Els missatges només s’accepten des dels comptes seguits", |     "DM bounce": "Els missatges només s’accepten des dels comptes seguits", | ||||||
|     "Next": "Pròxim", |     "Next": "Pròxim", | ||||||
|     "Preview": "Vista prèvia", |     "Preview": "Vista prèvia", | ||||||
|     "Linked": "enllaç web" |     "Linked": "enllaç web", | ||||||
|  |     "hashtag": "etiqueta", | ||||||
|  |     "smile": "somriure", | ||||||
|  |     "wink": "fer l'ullet" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Dim ond o gyfrifon a ddilynir y derbynnir negeseuon", |     "DM bounce": "Dim ond o gyfrifon a ddilynir y derbynnir negeseuon", | ||||||
|     "Next": "Nesaf", |     "Next": "Nesaf", | ||||||
|     "Preview": "Rhagolwg", |     "Preview": "Rhagolwg", | ||||||
|     "Linked": "Dolen we" |     "Linked": "Dolen we", | ||||||
|  |     "hashtag": "hash-nod", | ||||||
|  |     "smile": "gwenu", | ||||||
|  |     "wink": "winc" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Nachrichten werden nur von folgenden Konten akzeptiert", |     "DM bounce": "Nachrichten werden nur von folgenden Konten akzeptiert", | ||||||
|     "Next": "Nächster", |     "Next": "Nächster", | ||||||
|     "Preview": "Vorschau", |     "Preview": "Vorschau", | ||||||
|     "Linked": "Weblink" |     "Linked": "Weblink", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "Lächeln", | ||||||
|  |     "wink": "zwinkern" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Messages are only accepted from followed accounts", |     "DM bounce": "Messages are only accepted from followed accounts", | ||||||
|     "Next": "Next", |     "Next": "Next", | ||||||
|     "Preview": "Preview", |     "Preview": "Preview", | ||||||
|     "Linked": "Web linked" |     "Linked": "Web linked", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "smile", | ||||||
|  |     "wink": "wink" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Solo se aceptan mensajes de cuentas seguidas", |     "DM bounce": "Solo se aceptan mensajes de cuentas seguidas", | ||||||
|     "Next": "Próxima", |     "Next": "Próxima", | ||||||
|     "Preview": "Avance", |     "Preview": "Avance", | ||||||
|     "Linked": "enlace web" |     "Linked": "enlace web", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "sonreír", | ||||||
|  |     "wink": "guiño" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Les messages ne sont acceptés que des comptes suivis", |     "DM bounce": "Les messages ne sont acceptés que des comptes suivis", | ||||||
|     "Next": "Suivante", |     "Next": "Suivante", | ||||||
|     "Preview": "Aperçu", |     "Preview": "Aperçu", | ||||||
|     "Linked": "lien Web" |     "Linked": "lien Web", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "le sourire", | ||||||
|  |     "wink": "clin d'œil" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Ní ghlactar le teachtaireachtaí ach ó chuntais a leanann", |     "DM bounce": "Ní ghlactar le teachtaireachtaí ach ó chuntais a leanann", | ||||||
|     "Next": "Ar Aghaidh", |     "Next": "Ar Aghaidh", | ||||||
|     "Preview": "Réamhamharc", |     "Preview": "Réamhamharc", | ||||||
|     "Linked": "Nasc gréasáin" |     "Linked": "Nasc gréasáin", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "aoibh gháire", | ||||||
|  |     "wink": "wink" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "संदेश केवल अनुसरण किए गए खातों से स्वीकार किए जाते हैं", |     "DM bounce": "संदेश केवल अनुसरण किए गए खातों से स्वीकार किए जाते हैं", | ||||||
|     "Next": "अगला", |     "Next": "अगला", | ||||||
|     "Preview": "पूर्वावलोकन", |     "Preview": "पूर्वावलोकन", | ||||||
|     "Linked": "वेब लिंक" |     "Linked": "वेब लिंक", | ||||||
|  |     "hashtag": "हैशटैग", | ||||||
|  |     "smile": "मुस्कुराओ", | ||||||
|  |     "wink": "आँख मारना" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "I messaggi sono accettati solo dagli account seguiti", |     "DM bounce": "I messaggi sono accettati solo dagli account seguiti", | ||||||
|     "Next": "Il prossimo", |     "Next": "Il prossimo", | ||||||
|     "Preview": "Anteprima", |     "Preview": "Anteprima", | ||||||
|     "Linked": "collegamento web" |     "Linked": "collegamento web", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "Sorridi", | ||||||
|  |     "wink": "occhiolino" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "メッセージはフォローされているアカウントからのみ受け付けられます", |     "DM bounce": "メッセージはフォローされているアカウントからのみ受け付けられます", | ||||||
|     "Next": "次", |     "Next": "次", | ||||||
|     "Preview": "プレビュー", |     "Preview": "プレビュー", | ||||||
|     "Linked": "ウェブリンク" |     "Linked": "ウェブリンク", | ||||||
|  |     "hashtag": "ハッシュタグ", | ||||||
|  |     "smile": "スマイル", | ||||||
|  |     "wink": "ウィンク" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -370,5 +370,8 @@ | ||||||
|     "DM bounce": "Messages are only accepted from followed accounts", |     "DM bounce": "Messages are only accepted from followed accounts", | ||||||
|     "Next": "Next", |     "Next": "Next", | ||||||
|     "Preview": "Preview", |     "Preview": "Preview", | ||||||
|     "Linked": "Web link" |     "Linked": "Web link", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "smile", | ||||||
|  |     "wink": "wink" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Mensagens são aceitas apenas de contas seguidas", |     "DM bounce": "Mensagens são aceitas apenas de contas seguidas", | ||||||
|     "Next": "Próxima", |     "Next": "Próxima", | ||||||
|     "Preview": "Antevisão", |     "Preview": "Antevisão", | ||||||
|     "Linked": "link da web" |     "Linked": "link da web", | ||||||
|  |     "hashtag": "hash-tag", | ||||||
|  |     "smile": "sorrir", | ||||||
|  |     "wink": "piscar" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "Сообщения принимаются только от следующих аккаунтов", |     "DM bounce": "Сообщения принимаются только от следующих аккаунтов", | ||||||
|     "Next": "Следующий", |     "Next": "Следующий", | ||||||
|     "Preview": "Предварительный просмотр", |     "Preview": "Предварительный просмотр", | ||||||
|     "Linked": "интернет-ссылка" |     "Linked": "интернет-ссылка", | ||||||
|  |     "hashtag": "хэштег", | ||||||
|  |     "smile": "улыбка", | ||||||
|  |     "wink": "подмигивание" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -374,5 +374,8 @@ | ||||||
|     "DM bounce": "仅接受来自后续帐户的邮件", |     "DM bounce": "仅接受来自后续帐户的邮件", | ||||||
|     "Next": "下一个", |     "Next": "下一个", | ||||||
|     "Preview": "预览", |     "Preview": "预览", | ||||||
|     "Linked": "网页链接" |     "Linked": "网页链接", | ||||||
|  |     "hashtag": "井号", | ||||||
|  |     "smile": "微笑", | ||||||
|  |     "wink": "眨眼" | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue