mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main
commit
c67d1837e5
|
|
@ -10,6 +10,7 @@ import os
|
||||||
import html
|
import html
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
from select import select
|
||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
from person import createPerson
|
from person import createPerson
|
||||||
|
|
@ -2009,7 +2010,11 @@ if args.speaker:
|
||||||
os.system(speakerCmd)
|
os.system(speakerCmd)
|
||||||
|
|
||||||
prevSay = speakerJson['say']
|
prevSay = speakerJson['say']
|
||||||
time.sleep(30)
|
|
||||||
|
# wait for a while, or until a key is pressed
|
||||||
|
rlist, wlist, xlist = select([sys.stdin], [], [], 30)
|
||||||
|
if rlist:
|
||||||
|
print("Key pressed..." + str(rlist))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if federationList:
|
if federationList:
|
||||||
|
|
|
||||||
64
speaker.py
64
speaker.py
|
|
@ -248,7 +248,7 @@ def getSpeakerFromServer(baseDir: str, session,
|
||||||
|
|
||||||
def _speakerEndpointJson(displayName: str, summary: str,
|
def _speakerEndpointJson(displayName: str, summary: str,
|
||||||
content: str, imageDescription: str,
|
content: str, imageDescription: str,
|
||||||
links: [], gender: str) -> {}:
|
links: [], gender: str, postId: str) -> {}:
|
||||||
"""Returns a json endpoint for the TTS speaker
|
"""Returns a json endpoint for the TTS speaker
|
||||||
"""
|
"""
|
||||||
speakerJson = {
|
speakerJson = {
|
||||||
|
|
@ -256,13 +256,29 @@ def _speakerEndpointJson(displayName: str, summary: str,
|
||||||
"summary": summary,
|
"summary": summary,
|
||||||
"say": content,
|
"say": content,
|
||||||
"imageDescription": imageDescription,
|
"imageDescription": imageDescription,
|
||||||
"detectedLinks": links
|
"detectedLinks": links,
|
||||||
|
"id": postId
|
||||||
}
|
}
|
||||||
if gender:
|
if gender:
|
||||||
speakerJson['gender'] = gender
|
speakerJson['gender'] = gender
|
||||||
return speakerJson
|
return speakerJson
|
||||||
|
|
||||||
|
|
||||||
|
def _SSMLheader(systemLanguage: str, instanceTitle: str) -> str:
|
||||||
|
"""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' + \
|
||||||
|
' <dc:title xml:lang="' + systemLanguage + '">' + \
|
||||||
|
instanceTitle + ' inbox</dc:title>\n' + \
|
||||||
|
' </metadata>\n'
|
||||||
|
|
||||||
|
|
||||||
def _speakerEndpointSSML(displayName: str, summary: str,
|
def _speakerEndpointSSML(displayName: str, summary: str,
|
||||||
content: str, imageDescription: str,
|
content: str, imageDescription: str,
|
||||||
links: [], language: str,
|
links: [], language: str,
|
||||||
|
|
@ -289,16 +305,7 @@ def _speakerEndpointSSML(displayName: str, summary: str,
|
||||||
|
|
||||||
content = _addSSMLemphasis(content)
|
content = _addSSMLemphasis(content)
|
||||||
voiceParams = 'name="' + displayName + '" gender="' + gender + '"'
|
voiceParams = 'name="' + displayName + '" gender="' + gender + '"'
|
||||||
return '<?xml version="1.0"?>\n' + \
|
return _SSMLheader(langShort, instanceTitle) + \
|
||||||
'<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' + \
|
|
||||||
' <dc:title xml:lang="' + langShort + '">' + \
|
|
||||||
instanceTitle + ' inbox</dc:title>\n' + \
|
|
||||||
' </metadata>\n' + \
|
|
||||||
' <p>\n' + \
|
' <p>\n' + \
|
||||||
' <s xml:lang="' + language + '">\n' + \
|
' <s xml:lang="' + language + '">\n' + \
|
||||||
' <voice ' + voiceParams + '>\n' + \
|
' <voice ' + voiceParams + '>\n' + \
|
||||||
|
|
@ -338,11 +345,13 @@ def getSSMLbox(baseDir: str, path: str,
|
||||||
instanceTitle, gender)
|
instanceTitle, gender)
|
||||||
|
|
||||||
|
|
||||||
def updateSpeaker(baseDir: str, nickname: str, domain: str,
|
def _postToSpeakerJson(baseDir: str, nickname: str, domain: str,
|
||||||
postJsonObject: {}, personCache: {},
|
postJsonObject: {}, personCache: {},
|
||||||
translate: {}, announcingActor: str) -> None:
|
translate: {}, announcingActor: str) -> {}:
|
||||||
""" Generates a json file which can be used for TTS announcement
|
"""Converts an ActivityPub post into some Json containing
|
||||||
of incoming inbox posts
|
speech synthesis parameters.
|
||||||
|
NOTE: There currently appears to be no standardized json
|
||||||
|
format for speech synthesis
|
||||||
"""
|
"""
|
||||||
if not postJsonObject.get('object'):
|
if not postJsonObject.get('object'):
|
||||||
return
|
return
|
||||||
|
|
@ -352,8 +361,6 @@ def updateSpeaker(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
if not isinstance(postJsonObject['object']['content'], str):
|
if not isinstance(postJsonObject['object']['content'], str):
|
||||||
return
|
return
|
||||||
speakerFilename = \
|
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
|
||||||
detectedLinks = []
|
detectedLinks = []
|
||||||
content = urllib.parse.unquote_plus(postJsonObject['object']['content'])
|
content = urllib.parse.unquote_plus(postJsonObject['object']['content'])
|
||||||
content = html.unescape(content)
|
content = html.unescape(content)
|
||||||
|
|
@ -397,7 +404,24 @@ def updateSpeaker(baseDir: str, nickname: str, domain: str,
|
||||||
announcedHandle = announcedNickname + '@' + announcedDomain
|
announcedHandle = announcedNickname + '@' + announcedDomain
|
||||||
content = \
|
content = \
|
||||||
translate['announces'] + ' ' + announcedHandle + '. ' + content
|
translate['announces'] + ' ' + announcedHandle + '. ' + content
|
||||||
speakerJson = _speakerEndpointJson(speakerName, summary,
|
postId = None
|
||||||
|
if postJsonObject['object'].get('id'):
|
||||||
|
postId = postJsonObject['object']['id']
|
||||||
|
return _speakerEndpointJson(speakerName, summary,
|
||||||
content, imageDescription,
|
content, imageDescription,
|
||||||
detectedLinks, gender)
|
detectedLinks, gender, postId)
|
||||||
|
|
||||||
|
|
||||||
|
def updateSpeaker(baseDir: str, nickname: str, domain: str,
|
||||||
|
postJsonObject: {}, personCache: {},
|
||||||
|
translate: {}, announcingActor: str) -> None:
|
||||||
|
""" Generates a json file which can be used for TTS announcement
|
||||||
|
of incoming inbox posts
|
||||||
|
"""
|
||||||
|
speakerJson = \
|
||||||
|
_postToSpeakerJson(baseDir, nickname, domain,
|
||||||
|
postJsonObject, personCache,
|
||||||
|
translate, announcingActor)
|
||||||
|
speakerFilename = \
|
||||||
|
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
||||||
saveJson(speakerJson, speakerFilename)
|
saveJson(speakerJson, speakerFilename)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue