Compare commits

...

2 Commits

Author SHA1 Message Date
Alex Orid
56416acf77 Fixes 2021-04-28 22:45:55 -04:00
Alex Orid
2ba271c4a3 typo 2021-04-28 16:32:08 -04:00
8 changed files with 57 additions and 20 deletions

View File

@ -8,4 +8,4 @@ RUN pip3 install -r requirements_sa_command.txt
COPY . .
CMD [ "python3", "standalone_tts_core.py"]
CMD [ "python3", "standalone_command.py"]

View File

@ -8,4 +8,4 @@ RUN pip3 install -r requirements_sa_command.txt
COPY . .
CMD [ "python3", "standalone_command.py"]
CMD [ "python3", "standalone_tts_core.py"]

View File

@ -6,6 +6,8 @@ from json import loads
from urllib.parse import urlencode
import requests
import threading
class ChannelReward_Hydration(AbstractChannelRewards, metaclass=ABCMeta):
"""
this is the hydration reward.
@ -16,12 +18,25 @@ class ChannelReward_Hydration(AbstractChannelRewards, metaclass=ABCMeta):
super().__init__(ChannelReward_Hydration.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
self.help = ["This is a hydration channel point reward."]
self.isChannelRewardEnabled = True
self.threads = []
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
#print("sending:",user, 16, "!lights hydration")
self.dothething(user, 16, "!lights hydration", "")
self.send_TTS(user, rewardPrompt)
try:
if self.is_ChannelReward_enabled:
thread_ = threading.Thread(target=self.dothething, args=(user, 16, "!lights hydration", ""))
thread_.daemon = True
self.threads.append(thread_)
thread_.start()
if self.is_ChannelReward_enabled:
thread_ = threading.Thread(target=self.send_TTS, args=(user, rewardPrompt))
thread_.daemon = True
self.threads.append(thread_)
thread_.start()
except:
pass
return None
def dothething(self, username, light_group, command, rest):

View File

@ -40,5 +40,21 @@ class ChannelReward_RubiksCube(AbstractChannelRewards, metaclass=ABCMeta):
# todo handle failed requests
pass
def send_TTS(self, username, message):
params = urlencode({'tts_sender': username, 'tts_text': message})
#standalone_tts_core
url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def get_help(self):
return self.help

View File

@ -37,7 +37,7 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta):
praxis_logger_obj.log(user_)
praxis_logger_obj.log(user)
returnString = self.dothething(user, 16, command, rest)
isTwitch = True
isTwitch = True
if isTwitch == False:
returnString = self.dothething(user, 16, command, rest)

View File

@ -106,7 +106,7 @@ class Lights_Module():
def hydration(self):
self.bridge_.run_scene("Downstairs", "hydration")
sleep(20)
sleep(4)
self.bridge_.run_scene("Downstairs", "Stream")
def raveMode(self):

View File

@ -21,21 +21,22 @@ def init():
def send_text(tts_sender, tts_text):
#Play Audio File
#Play Text
params = urlencode({'tts_sender': tts_sender, 'tts_text': tts_text})
url = "http://localhost:93986/api/v1/tts/speech?%s" % params
url = "http://192.168.191.208:40085/api/v1/tts/speech?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
pass
else:
#msg = data['message']
#if msg is not None:
#pass
#else:
# todo handle failed requests
pass
#pass
#return None
return flask.make_response('', 200)
@api.route('/api/v1/tts/send_text', methods=['GET'])
@ -48,5 +49,6 @@ def tts_send_text():
return send_text(request.args['tts_sender'], request.args['tts_text'])
if __name__ == '__main__':
init()
#send_text("","Blah Blah Blah")
#init()
api.run(host='0.0.0.0', port=60809)

View File

@ -35,18 +35,20 @@ def isTTS_URL_Check(message):
if not is_ttsEnabled:
isNotBlocked = False
return isNotBlocked
return not isNotBlocked
def try_TTS(tts_sender, tts_text):
text_to_say: str = "%s says, %s" % (tts_sender, tts_text)
if tts_sender is None:
#tts.tts(str(text_to_say))
#tts.tts(str(tts_text))
if tts_sender == "":
text_to_say = tts_text
if isTTS_URL_Check(tts_text):
if not utility.contains_slur(tts_sender):
if not utility.contains_slur(text_to_say):
tts.tts(text_to_say)
tts.tts(str(text_to_say))
return flask.make_response('', 200)
@ -54,11 +56,13 @@ def try_TTS(tts_sender, tts_text):
def tts_speech():
if 'tts_sender' not in request.args:
tts_sender = ""
else:
tts_sender = request.args['tts_sender']
if 'tts_text' not in request.args:
return flask.make_response('{\"text\":"Argument \'tts_text\' not in request"}', 400)
return try_TTS(request.args['tts_text'])
return try_TTS(tts_sender, request.args['tts_text'])
if __name__ == '__main__':
init()
api.run(host='0.0.0.0', port=93986)
#init()
api.run(host='0.0.0.0', port=40085)