epicyon/speaker.py

553 lines
20 KiB
Python
Raw Normal View History

2021-03-01 19:16:33 +00:00
__filename__ = "speaker.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
2021-09-10 16:14:50 +00:00
__email__ = "bob@libreserver.org"
2021-03-01 19:16:33 +00:00
__status__ = "Production"
2021-06-26 11:27:14 +00:00
__module_group__ = "Accessibility"
2021-03-01 19:16:33 +00:00
2021-03-02 12:39:18 +00:00
import os
2021-03-03 19:06:18 +00:00
import html
2021-03-01 19:16:33 +00:00
import random
2021-03-03 19:06:18 +00:00
import urllib.parse
2021-12-27 11:20:57 +00:00
from utils import remove_id_ending
2021-12-26 20:12:18 +00:00
from utils import is_dm
2021-12-26 19:36:40 +00:00
from utils import is_reply
2021-12-26 20:39:35 +00:00
from utils import camel_case_split
2021-12-27 19:05:25 +00:00
from utils import get_domain_from_actor
2021-12-27 22:19:18 +00:00
from utils import get_nickname_from_actor
2021-12-27 22:12:29 +00:00
from utils import get_gender_from_bio
2021-12-27 21:59:07 +00:00
from utils import get_display_name
2021-12-27 15:43:22 +00:00
from utils import remove_html
2021-12-26 15:13:34 +00:00
from utils import load_json
2021-12-26 14:47:21 +00:00
from utils import save_json
2021-12-26 19:15:36 +00:00
from utils import is_pgp_encrypted
2021-12-26 10:57:03 +00:00
from utils import has_object_dict
2021-12-26 12:02:29 +00:00
from utils import acct_dir
2021-12-26 10:19:59 +00:00
from utils import local_actor_url
2021-12-29 21:55:09 +00:00
from content import html_replace_quote_marks
2021-03-01 19:16:33 +00:00
2021-03-03 12:34:46 +00:00
speakerRemoveChars = ('.\n', '. ', ',', ';', '?', '!')
2021-03-01 19:16:33 +00:00
2021-12-29 21:55:09 +00:00
def get_speaker_pitch(displayName: str, screenreader: str, gender) -> int:
2021-03-01 19:16:33 +00:00
"""Returns the speech synthesis pitch for the given name
"""
random.seed(displayName)
rangeMin = 1
rangeMax = 100
if 'She' in gender:
rangeMin = 50
elif 'Him' in gender:
rangeMax = 50
2021-03-02 15:13:10 +00:00
if screenreader == 'picospeaker':
2021-03-03 20:19:56 +00:00
rangeMin = -6
rangeMax = 3
if 'She' in gender:
rangeMin = -1
elif 'Him' in gender:
rangeMax = -1
return random.randint(rangeMin, rangeMax)
2021-03-01 19:16:33 +00:00
2021-12-29 21:55:09 +00:00
def get_speaker_rate(displayName: str, screenreader: str) -> int:
2021-03-01 19:16:33 +00:00
"""Returns the speech synthesis rate for the given name
"""
random.seed(displayName)
2021-03-02 15:13:10 +00:00
if screenreader == 'picospeaker':
2021-03-03 21:21:17 +00:00
return random.randint(-40, -20)
2021-03-01 19:16:33 +00:00
return random.randint(50, 120)
2021-12-29 21:55:09 +00:00
def get_speaker_range(displayName: str) -> int:
2021-03-01 19:16:33 +00:00
"""Returns the speech synthesis range for the given name
"""
random.seed(displayName)
return random.randint(300, 800)
2021-12-29 21:55:09 +00:00
def _speaker_pronounce(base_dir: str, sayText: str, translate: {}) -> str:
2021-03-02 12:39:18 +00:00
"""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
"""
2021-12-25 16:17:53 +00:00
pronounceFilename = base_dir + '/accounts/speaker_pronounce.txt'
2021-03-03 19:15:32 +00:00
convertDict = {}
if translate:
convertDict = {
"Epicyon": "Epi-cyon",
"espeak": "e-speak",
"emoji": "emowji",
"clearnet": "clear-net",
"https": "H-T-T-P-S",
"HTTPS": "H-T-T-P-S",
2021-03-03 20:41:22 +00:00
"XMPP": "X-M-P-P",
"xmpp": "X-M-P-P",
2021-03-03 22:26:54 +00:00
"sql": "S-Q-L",
2021-03-08 22:02:54 +00:00
".js": " dot J-S",
2021-03-04 11:51:30 +00:00
"PSQL": "Postgres S-Q-L",
2021-03-03 22:26:54 +00:00
"SQL": "S-Q-L",
2021-03-11 12:44:47 +00:00
"gdpr": "G-D-P-R",
2021-03-13 10:07:57 +00:00
"kde": "K-D-E",
2021-03-14 11:17:37 +00:00
"AGPL": "Affearo G-P-L",
"agpl": "Affearo G-P-L",
"GPL": "G-P-L",
"gpl": "G-P-L",
2021-03-04 15:54:52 +00:00
"coop": "co-op",
2021-03-04 11:51:30 +00:00
"KMail": "K-Mail",
2021-03-13 10:10:02 +00:00
"kmail": "K-Mail",
2021-03-04 11:51:30 +00:00
"gmail": "G-mail",
"Gmail": "G-mail",
"OpenPGP": "Open P-G-P",
2021-03-03 19:15:32 +00:00
"Tor": "Toor",
2021-03-10 18:44:44 +00:00
"memes": "meemes",
"Memes": "Meemes",
2021-03-10 20:43:02 +00:00
"rofl": "roll on the floor laughing",
"ROFL": "roll on the floor laughing",
2021-03-10 13:45:34 +00:00
"fwiw": "for what it's worth",
"fyi": "for your information",
2021-03-10 21:08:18 +00:00
"irl": "in real life",
"IRL": "in real life",
2021-03-10 13:45:34 +00:00
"imho": "in my opinion",
2021-03-09 20:06:26 +00:00
"fediverse": "fediiverse",
"Fediverse": "Fediiverse",
2021-03-04 16:46:21 +00:00
" foss ": " free and open source software ",
" floss ": " free libre and open source software ",
" FOSS ": "free and open source software",
" FLOSS ": "free libre and open source software",
" oss ": " open source software ",
" OSS ": " open source software ",
2021-03-03 19:15:32 +00:00
"🤔": ". " + translate["thinking emoji"],
"RT @": "Re-Tweet ",
2021-03-03 20:56:35 +00:00
"#nowplaying": translate["hashtag"] + " now-playing",
"#NowPlaying": translate["hashtag"] + " now-playing",
2021-03-03 20:59:21 +00:00
"#": translate["hashtag"] + ' ',
2021-03-03 19:15:32 +00:00
":D": '. ' + translate["laughing"],
":-D": '. ' + translate["laughing"],
":)": '. ' + translate["smile"],
";)": '. ' + translate["wink"],
":(": '. ' + translate["sad face"],
":-)": '. ' + translate["smile"],
":-(": '. ' + translate["sad face"],
";-)": '. ' + translate["wink"],
2021-03-10 10:43:53 +00:00
":O": '. ' + translate['shocked'],
2021-03-04 15:54:52 +00:00
"?": "? ",
2021-03-04 16:20:24 +00:00
'"': "'",
2021-03-03 21:30:01 +00:00
"*": "",
"(": ",",
")": ","
2021-03-03 19:15:32 +00:00
}
2021-03-02 12:39:18 +00:00
if os.path.isfile(pronounceFilename):
with open(pronounceFilename, 'r') as fp:
pronounceList = fp.readlines()
2021-03-02 12:39:18 +00:00
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
2021-12-29 21:55:09 +00:00
def speaker_replace_links(sayText: str, translate: {},
detectedLinks: []) -> str:
"""Replaces any links in the given text with "link to [domain]".
Instead of reading out potentially very long and meaningless links
"""
text = sayText
2021-03-18 18:37:55 +00:00
text = text.replace('?v=', '__v=')
2021-03-03 12:34:46 +00:00
for ch in speakerRemoveChars:
text = text.replace(ch, ' ')
2021-03-18 18:37:55 +00:00
text = text.replace('__v=', '?v=')
replacements = {}
wordsList = text.split(' ')
2021-03-03 19:15:32 +00:00
if translate.get('Linked'):
linkedStr = translate['Linked']
else:
linkedStr = 'Linked'
2021-03-02 14:05:43 +00:00
prevWord = ''
for word in wordsList:
2021-03-11 11:35:03 +00:00
if word.startswith('v='):
2021-03-11 12:24:20 +00:00
replacements[word] = ''
2021-03-02 16:50:32 +00:00
if word.startswith(':'):
if word.endswith(':'):
2021-03-02 17:18:47 +00:00
replacements[word] = ', emowji ' + word.replace(':', '') + ','
2021-03-02 16:50:32 +00:00
continue
2021-03-02 14:09:51 +00:00
if word.startswith('@') and not prevWord.endswith('RT'):
2021-03-11 11:35:03 +00:00
# replace mentions, but not re-tweets
2021-03-03 19:15:32 +00:00
if translate.get('mentioning'):
replacements[word] = \
2021-03-04 11:52:22 +00:00
translate['mentioning'] + ' ' + word[1:] + ', '
2021-03-02 14:05:43 +00:00
prevWord = word
domain = None
2021-12-26 10:00:46 +00:00
domain_full = None
if 'https://' in word:
domain = word.split('https://')[1]
2021-12-26 10:00:46 +00:00
domain_full = 'https://' + domain
elif 'http://' in word:
domain = word.split('http://')[1]
2021-12-26 10:00:46 +00:00
domain_full = 'http://' + domain
if not domain:
continue
if '/' in domain:
domain = domain.split('/')[0]
if domain.startswith('www.'):
domain = domain.replace('www.', '')
2021-12-26 10:00:46 +00:00
replacements[domain_full] = '. ' + linkedStr + ' ' + domain + '.'
detectedLinks.append(domain_full)
for replaceStr, newStr in replacements.items():
sayText = sayText.replace(replaceStr, newStr)
return sayText.replace('..', '.')
2021-12-29 21:55:09 +00:00
def _add_ssm_lemphasis(sayText: str) -> str:
2021-03-03 12:34:46 +00:00
"""Adds emphasis to *emphasised* text
"""
if '*' not in sayText:
return sayText
text = sayText
for ch in speakerRemoveChars:
text = text.replace(ch, ' ')
wordsList = text.split(' ')
replacements = {}
for word in wordsList:
if word.startswith('*'):
if word.endswith('*'):
replacements[word] = \
'<emphasis level="strong">' + \
word.replace('*', '') + \
'</emphasis>'
for replaceStr, newStr in replacements.items():
sayText = sayText.replace(replaceStr, newStr)
return sayText
2021-12-29 21:55:09 +00:00
def _remove_emoji_from_text(sayText: str) -> str:
2021-03-03 18:24:37 +00:00
"""Removes :emoji: from the given text
"""
2021-03-03 20:18:14 +00:00
if ':' not in sayText:
2021-03-03 18:24:37 +00:00
return sayText
text = sayText
for ch in speakerRemoveChars:
text = text.replace(ch, ' ')
wordsList = text.split(' ')
replacements = {}
for word in wordsList:
if word.startswith(':'):
if word.endswith(':'):
2021-03-03 22:05:56 +00:00
replacements[word] = ''
2021-03-03 18:24:37 +00:00
for replaceStr, newStr in replacements.items():
sayText = sayText.replace(replaceStr, newStr)
return sayText.replace(' ', ' ').strip()
2021-12-29 21:55:09 +00:00
def _speaker_endpoint_json(displayName: str, summary: str,
content: str, sayContent: str,
imageDescription: str,
links: [], gender: str, post_id: str,
postDM: bool, postReply: bool,
followRequestsExist: bool,
followRequestsList: [],
likedBy: str, published: str, postCal: bool,
postShare: bool, theme_name: str,
isDirect: bool, replyToYou: bool) -> {}:
2021-03-03 12:34:46 +00:00
"""Returns a json endpoint for the TTS speaker
"""
2021-03-03 13:02:47 +00:00
speakerJson = {
2021-03-03 12:34:46 +00:00
"name": displayName,
"summary": summary,
2021-03-11 10:10:56 +00:00
"content": content,
"say": sayContent,
"published": published,
2021-03-03 12:34:46 +00:00
"imageDescription": imageDescription,
"detectedLinks": links,
2021-12-26 19:47:06 +00:00
"id": post_id,
"direct": isDirect,
"replyToYou": replyToYou,
"notify": {
2021-12-25 23:35:50 +00:00
"theme": theme_name,
"dm": postDM,
2021-03-09 15:01:35 +00:00
"reply": postReply,
"followRequests": followRequestsExist,
"followRequestsList": followRequestsList,
"likedBy": likedBy,
"calendar": postCal,
"share": postShare
}
2021-03-03 12:34:46 +00:00
}
2021-03-03 13:02:47 +00:00
if gender:
speakerJson['gender'] = gender
return speakerJson
2021-03-03 12:34:46 +00:00
2021-12-29 21:55:09 +00:00
def _ssm_lheader(system_language: str, instanceTitle: str) -> str:
2021-03-04 10:25:36 +00:00
"""Returns a header for an SSML document
"""
return '<?xml version="1.0"?>\n' + \
'<speak xmlns="http://www.w3.org/2001/10/synthesis"\n' + \
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n' + \
' xsi:schemaLocation="http://www.w3.org/2001/10/synthesis\n' + \
' http://www.w3.org/TR/speech-synthesis11/synthesis.xsd"\n' + \
' version="1.1">\n' + \
' <metadata>\n' + \
2021-12-25 23:03:28 +00:00
' <dc:title xml:lang="' + system_language + '">' + \
2021-03-04 10:25:36 +00:00
instanceTitle + ' inbox</dc:title>\n' + \
' </metadata>\n'
2021-12-29 21:55:09 +00:00
def _speaker_endpoint_ssml(displayName: str, summary: str,
content: str, imageDescription: str,
links: [], language: str,
instanceTitle: str,
gender: str) -> str:
2021-03-03 12:34:46 +00:00
"""Returns an SSML endpoint for the TTS speaker
https://en.wikipedia.org/wiki/Speech_Synthesis_Markup_Language
https://www.w3.org/TR/speech-synthesis/
"""
langShort = 'en'
if language:
langShort = language[:2]
if not gender:
gender = 'neutral'
else:
if langShort == 'en':
gender = gender.lower()
2021-03-03 13:02:47 +00:00
if 'he/him' in gender:
2021-03-03 12:34:46 +00:00
gender = 'male'
2021-03-03 13:02:47 +00:00
elif 'she/her' in gender:
2021-03-03 12:34:46 +00:00
gender = 'female'
else:
gender = 'neutral'
2021-12-29 21:55:09 +00:00
content = _add_ssm_lemphasis(content)
2021-03-03 12:34:46 +00:00
voiceParams = 'name="' + displayName + '" gender="' + gender + '"'
2021-12-29 21:55:09 +00:00
return _ssm_lheader(langShort, instanceTitle) + \
2021-03-03 12:34:46 +00:00
' <p>\n' + \
' <s xml:lang="' + language + '">\n' + \
' <voice ' + voiceParams + '>\n' + \
' ' + content + '\n' + \
' </voice>\n' + \
' </s>\n' + \
' </p>\n' + \
'</speak>\n'
2021-12-29 21:55:09 +00:00
def get_ssm_lbox(base_dir: str, path: str,
domain: str,
system_language: str,
instanceTitle: str,
boxName: str) -> str:
2021-03-03 12:34:46 +00:00
"""Returns SSML for the given timeline
"""
nickname = path.split('/users/')[1]
if '/' in nickname:
nickname = nickname.split('/')[0]
speakerFilename = \
2021-12-26 12:02:29 +00:00
acct_dir(base_dir, nickname, domain) + '/speaker.json'
2021-03-03 12:34:46 +00:00
if not os.path.isfile(speakerFilename):
return None
2021-12-26 15:13:34 +00:00
speakerJson = load_json(speakerFilename)
2021-03-03 12:34:46 +00:00
if not speakerJson:
return None
gender = None
if speakerJson.get('gender'):
gender = speakerJson['gender']
2021-12-29 21:55:09 +00:00
return _speaker_endpoint_ssml(speakerJson['name'],
speakerJson['summary'],
speakerJson['say'],
speakerJson['imageDescription'],
speakerJson['detectedLinks'],
system_language,
instanceTitle, gender)
2021-03-03 19:06:18 +00:00
2021-12-29 21:55:09 +00:00
def speakable_text(base_dir: str, content: str, translate: {}) -> (str, []):
2021-03-18 17:27:46 +00:00
"""Convert the given text to a speakable version
which includes changes for prononciation
"""
2021-03-25 14:51:41 +00:00
content = str(content)
2021-12-26 19:15:36 +00:00
if is_pgp_encrypted(content):
2021-03-18 19:04:58 +00:00
return content, []
2021-03-18 17:27:46 +00:00
# replace some emoji before removing html
if ' <3' in content:
content = content.replace(' <3', ' ' + translate['heart'])
2021-12-29 21:55:09 +00:00
content = remove_html(html_replace_quote_marks(content))
2021-03-18 17:27:46 +00:00
detectedLinks = []
2021-12-29 21:55:09 +00:00
content = speaker_replace_links(content, translate, detectedLinks)
2021-03-18 17:27:46 +00:00
# replace all double spaces
while ' ' in content:
content = content.replace(' ', ' ')
content = content.replace(' . ', '. ').strip()
2021-12-29 21:55:09 +00:00
sayContent = _speaker_pronounce(base_dir, content, translate)
2021-03-18 17:27:46 +00:00
# replace all double spaces
while ' ' in sayContent:
sayContent = sayContent.replace(' ', ' ')
2021-03-18 19:04:58 +00:00
return sayContent.replace(' . ', '. ').strip(), detectedLinks
2021-03-18 17:27:46 +00:00
2021-12-29 21:55:09 +00:00
def _post_to_speaker_json(base_dir: str, http_prefix: str,
nickname: str, domain: str, domain_full: str,
post_json_object: {}, person_cache: {},
translate: {}, announcingActor: str,
theme_name: str) -> {}:
2021-03-04 10:11:30 +00:00
"""Converts an ActivityPub post into some Json containing
speech synthesis parameters.
NOTE: There currently appears to be no standardized json
format for speech synthesis
2021-03-03 19:06:18 +00:00
"""
2021-12-26 10:57:03 +00:00
if not has_object_dict(post_json_object):
2021-03-03 19:06:18 +00:00
return
2021-12-25 22:09:19 +00:00
if not post_json_object['object'].get('content'):
2021-03-03 19:06:18 +00:00
return
2021-12-25 22:09:19 +00:00
if not isinstance(post_json_object['object']['content'], str):
2021-03-03 19:06:18 +00:00
return
detectedLinks = []
2021-12-25 22:09:19 +00:00
content = urllib.parse.unquote_plus(post_json_object['object']['content'])
2021-03-03 19:06:18 +00:00
content = html.unescape(content)
content = content.replace('<p>', '').replace('</p>', ' ')
2021-12-26 19:15:36 +00:00
if not is_pgp_encrypted(content):
2021-03-11 17:15:32 +00:00
# replace some emoji before removing html
if ' <3' in content:
content = content.replace(' <3', ' ' + translate['heart'])
2021-12-29 21:55:09 +00:00
content = remove_html(html_replace_quote_marks(content))
content = speaker_replace_links(content, translate, detectedLinks)
2021-03-11 17:15:32 +00:00
# replace all double spaces
while ' ' in content:
content = content.replace(' ', ' ')
content = content.replace(' . ', '. ').strip()
sayContent = content
2021-12-29 21:55:09 +00:00
sayContent = _speaker_pronounce(base_dir, content, translate)
2021-03-11 17:15:32 +00:00
# replace all double spaces
while ' ' in sayContent:
sayContent = sayContent.replace(' ', ' ')
sayContent = sayContent.replace(' . ', '. ').strip()
else:
sayContent = content
2021-03-03 19:06:18 +00:00
imageDescription = ''
2021-12-25 22:09:19 +00:00
if post_json_object['object'].get('attachment'):
attachList = post_json_object['object']['attachment']
2021-03-03 19:06:18 +00:00
if isinstance(attachList, list):
for img in attachList:
if not isinstance(img, dict):
continue
if img.get('name'):
if isinstance(img['name'], str):
imageDescription += \
img['name'] + '. '
2021-12-26 20:12:18 +00:00
isDirect = is_dm(post_json_object)
2021-12-26 10:19:59 +00:00
actor = local_actor_url(http_prefix, nickname, domain_full)
2021-12-26 19:36:40 +00:00
replyToYou = is_reply(post_json_object, actor)
published = ''
2021-12-25 22:09:19 +00:00
if post_json_object['object'].get('published'):
published = post_json_object['object']['published']
2021-03-03 19:06:18 +00:00
summary = ''
2021-12-25 22:09:19 +00:00
if post_json_object['object'].get('summary'):
if isinstance(post_json_object['object']['summary'], str):
post_json_object_summary = post_json_object['object']['summary']
2021-03-03 19:06:18 +00:00
summary = \
2021-12-25 22:09:19 +00:00
urllib.parse.unquote_plus(post_json_object_summary)
2021-03-03 19:06:18 +00:00
summary = html.unescape(summary)
speakerName = \
2021-12-27 21:59:07 +00:00
get_display_name(base_dir, post_json_object['actor'], person_cache)
2021-03-03 19:06:18 +00:00
if not speakerName:
return
2021-12-29 21:55:09 +00:00
speakerName = _remove_emoji_from_text(speakerName)
2021-03-03 20:22:18 +00:00
speakerName = speakerName.replace('_', ' ')
2021-12-26 20:39:35 +00:00
speakerName = camel_case_split(speakerName)
2021-12-27 22:12:29 +00:00
gender = get_gender_from_bio(base_dir, post_json_object['actor'],
person_cache, translate)
2021-03-03 19:06:18 +00:00
if announcingActor:
2021-12-27 22:19:18 +00:00
announcedNickname = get_nickname_from_actor(announcingActor)
2021-12-27 19:05:25 +00:00
announcedDomain, announcedport = get_domain_from_actor(announcingActor)
2021-03-03 19:31:23 +00:00
if announcedNickname and announcedDomain:
announcedHandle = announcedNickname + '@' + announcedDomain
2021-03-11 10:10:56 +00:00
sayContent = \
translate['announces'] + ' ' + \
announcedHandle + '. ' + sayContent
content = \
translate['announces'] + ' ' + \
announcedHandle + '. ' + content
2021-12-26 19:47:06 +00:00
post_id = None
2021-12-25 22:09:19 +00:00
if post_json_object['object'].get('id'):
2021-12-27 11:20:57 +00:00
post_id = remove_id_ending(post_json_object['object']['id'])
2021-03-09 15:01:35 +00:00
followRequestsExist = False
followRequestsList = []
2021-12-26 12:02:29 +00:00
accountsDir = acct_dir(base_dir, nickname, domain_full)
2021-03-09 15:01:35 +00:00
approveFollowsFilename = accountsDir + '/followrequests.txt'
if os.path.isfile(approveFollowsFilename):
with open(approveFollowsFilename, 'r') as fp:
follows = fp.readlines()
2021-03-09 15:01:35 +00:00
if len(follows) > 0:
followRequestsExist = True
2021-03-15 20:45:41 +00:00
for i in range(len(follows)):
follows[i] = follows[i].strip()
2021-03-15 20:42:57 +00:00
followRequestsList = follows
2021-03-09 22:25:32 +00:00
postDM = False
dmFilename = accountsDir + '/.newDM'
if os.path.isfile(dmFilename):
postDM = True
postReply = False
replyFilename = accountsDir + '/.newReply'
if os.path.isfile(replyFilename):
postReply = True
2021-03-09 15:01:35 +00:00
likedBy = ''
likeFilename = accountsDir + '/.newLike'
if os.path.isfile(likeFilename):
with open(likeFilename, 'r') as fp:
likedBy = fp.read()
calendarFilename = accountsDir + '/.newCalendar'
postCal = os.path.isfile(calendarFilename)
shareFilename = accountsDir + '/.newShare'
postShare = os.path.isfile(shareFilename)
2021-03-09 15:01:35 +00:00
2021-12-29 21:55:09 +00:00
return _speaker_endpoint_json(speakerName, summary,
content, sayContent, imageDescription,
detectedLinks, gender, post_id,
postDM, postReply,
followRequestsExist,
followRequestsList,
likedBy, published,
postCal, postShare, theme_name,
isDirect, replyToYou)
def update_speaker(base_dir: str, http_prefix: str,
nickname: str, domain: str, domain_full: str,
post_json_object: {}, person_cache: {},
translate: {}, announcingActor: str,
theme_name: str) -> None:
2021-03-04 10:11:30 +00:00
""" Generates a json file which can be used for TTS announcement
of incoming inbox posts
"""
speakerJson = \
2021-12-29 21:55:09 +00:00
_post_to_speaker_json(base_dir, http_prefix,
nickname, domain, domain_full,
post_json_object, person_cache,
translate, announcingActor,
theme_name)
2021-12-26 12:02:29 +00:00
speakerFilename = acct_dir(base_dir, nickname, domain) + '/speaker.json'
2021-12-26 14:47:21 +00:00
save_json(speakerJson, speakerFilename)