Speak image descriptions

merge-requests/30/head
Bob Mottram 2021-03-01 20:27:35 +00:00
parent 5e85887cd1
commit 7062c0a1c8
2 changed files with 23 additions and 2 deletions

View File

@ -1951,7 +1951,13 @@ if args.speaker:
espeak.set_parameter(espeak.Parameter.Range, srange)
espeak.synth(html.unescape(speakerJson['name']))
time.sleep(3)
espeak.synth(html.unescape(speakerJson['say']))
if not speakerJson['imageDescription']:
sayStr = speakerJson['say']
else:
sayStr = speakerJson['say'] + '. ' + \
speakerJson['imageDescription']
espeak.synth(html.unescape(sayStr))
prevSay = speakerJson['say']
time.sleep(20)
sys.exit()

View File

@ -2157,18 +2157,33 @@ def _updateSpeaker(baseDir: str, nickname: str, domain: str,
content = urllib.parse.unquote_plus(postJsonObject['object']['content'])
content = html.unescape(content)
content = removeHtml(htmlReplaceQuoteMarks(content))
imageDescription = ''
if postJsonObject['object'].get('attachment'):
attachList = postJsonObject['object']['attachment']
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'] + '. '
summary = ''
if postJsonObject['object'].get('summary'):
if isinstance(postJsonObject['object']['summary'], str):
summary = \
urllib.parse.unquote_plus(postJsonObject['object']['summary'])
summary = html.unescape(summary)
speakerName = \
getDisplayName(baseDir, postJsonObject['actor'], personCache)
speakerJson = {
"name": speakerName,
"summary": summary,
"say": content
"say": content,
"imageDescription": imageDescription
}
saveJson(speakerJson, speakerFilename)