Compare commits
2 Commits
95a3189b36
...
56416acf77
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56416acf77 | ||
|
|
2ba271c4a3 |
@ -8,4 +8,4 @@ RUN pip3 install -r requirements_sa_command.txt
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
CMD [ "python3", "standalone_tts_core.py"]
|
CMD [ "python3", "standalone_command.py"]
|
||||||
@ -8,4 +8,4 @@ RUN pip3 install -r requirements_sa_command.txt
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
CMD [ "python3", "standalone_command.py"]
|
CMD [ "python3", "standalone_tts_core.py"]
|
||||||
@ -6,6 +6,8 @@ from json import loads
|
|||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
import threading
|
||||||
|
|
||||||
class ChannelReward_Hydration(AbstractChannelRewards, metaclass=ABCMeta):
|
class ChannelReward_Hydration(AbstractChannelRewards, metaclass=ABCMeta):
|
||||||
"""
|
"""
|
||||||
this is the hydration reward.
|
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)
|
super().__init__(ChannelReward_Hydration.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
|
||||||
self.help = ["This is a hydration channel point reward."]
|
self.help = ["This is a hydration channel point reward."]
|
||||||
self.isChannelRewardEnabled = True
|
self.isChannelRewardEnabled = True
|
||||||
|
self.threads = []
|
||||||
|
|
||||||
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
|
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
|
||||||
|
|
||||||
#print("sending:",user, 16, "!lights hydration")
|
#print("sending:",user, 16, "!lights hydration")
|
||||||
self.dothething(user, 16, "!lights hydration", "")
|
try:
|
||||||
self.send_TTS(user, rewardPrompt)
|
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
|
return None
|
||||||
|
|
||||||
def dothething(self, username, light_group, command, rest):
|
def dothething(self, username, light_group, command, rest):
|
||||||
|
|||||||
@ -40,5 +40,21 @@ class ChannelReward_RubiksCube(AbstractChannelRewards, metaclass=ABCMeta):
|
|||||||
# todo handle failed requests
|
# todo handle failed requests
|
||||||
pass
|
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):
|
def get_help(self):
|
||||||
return self.help
|
return self.help
|
||||||
@ -37,7 +37,7 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta):
|
|||||||
praxis_logger_obj.log(user_)
|
praxis_logger_obj.log(user_)
|
||||||
praxis_logger_obj.log(user)
|
praxis_logger_obj.log(user)
|
||||||
returnString = self.dothething(user, 16, command, rest)
|
returnString = self.dothething(user, 16, command, rest)
|
||||||
isTwitch = True
|
isTwitch = True
|
||||||
|
|
||||||
if isTwitch == False:
|
if isTwitch == False:
|
||||||
returnString = self.dothething(user, 16, command, rest)
|
returnString = self.dothething(user, 16, command, rest)
|
||||||
|
|||||||
@ -106,7 +106,7 @@ class Lights_Module():
|
|||||||
|
|
||||||
def hydration(self):
|
def hydration(self):
|
||||||
self.bridge_.run_scene("Downstairs", "hydration")
|
self.bridge_.run_scene("Downstairs", "hydration")
|
||||||
sleep(20)
|
sleep(4)
|
||||||
self.bridge_.run_scene("Downstairs", "Stream")
|
self.bridge_.run_scene("Downstairs", "Stream")
|
||||||
|
|
||||||
def raveMode(self):
|
def raveMode(self):
|
||||||
|
|||||||
@ -21,21 +21,22 @@ def init():
|
|||||||
|
|
||||||
def send_text(tts_sender, tts_text):
|
def send_text(tts_sender, tts_text):
|
||||||
|
|
||||||
#Play Audio File
|
#Play Text
|
||||||
params = urlencode({'tts_sender': tts_sender, 'tts_text': tts_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)
|
resp = requests.get(url)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
print("Got the following message: %s" % resp.text)
|
print("Got the following message: %s" % resp.text)
|
||||||
data = loads(resp.text)
|
data = loads(resp.text)
|
||||||
msg = data['message']
|
#msg = data['message']
|
||||||
if msg is not None:
|
#if msg is not None:
|
||||||
pass
|
#pass
|
||||||
else:
|
#else:
|
||||||
# todo handle failed requests
|
# todo handle failed requests
|
||||||
pass
|
#pass
|
||||||
|
|
||||||
|
#return None
|
||||||
return flask.make_response('', 200)
|
return flask.make_response('', 200)
|
||||||
|
|
||||||
@api.route('/api/v1/tts/send_text', methods=['GET'])
|
@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'])
|
return send_text(request.args['tts_sender'], request.args['tts_text'])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
init()
|
#send_text("","Blah Blah Blah")
|
||||||
|
#init()
|
||||||
api.run(host='0.0.0.0', port=60809)
|
api.run(host='0.0.0.0', port=60809)
|
||||||
@ -35,18 +35,20 @@ def isTTS_URL_Check(message):
|
|||||||
if not is_ttsEnabled:
|
if not is_ttsEnabled:
|
||||||
isNotBlocked = False
|
isNotBlocked = False
|
||||||
|
|
||||||
return isNotBlocked
|
return not isNotBlocked
|
||||||
|
|
||||||
def try_TTS(tts_sender, tts_text):
|
def try_TTS(tts_sender, tts_text):
|
||||||
text_to_say: str = "%s says, %s" % (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
|
text_to_say = tts_text
|
||||||
|
|
||||||
if isTTS_URL_Check(tts_text):
|
if isTTS_URL_Check(tts_text):
|
||||||
if not utility.contains_slur(tts_sender):
|
if not utility.contains_slur(tts_sender):
|
||||||
if not utility.contains_slur(text_to_say):
|
if not utility.contains_slur(text_to_say):
|
||||||
tts.tts(text_to_say)
|
tts.tts(str(text_to_say))
|
||||||
|
|
||||||
return flask.make_response('', 200)
|
return flask.make_response('', 200)
|
||||||
|
|
||||||
@ -54,11 +56,13 @@ def try_TTS(tts_sender, tts_text):
|
|||||||
def tts_speech():
|
def tts_speech():
|
||||||
if 'tts_sender' not in request.args:
|
if 'tts_sender' not in request.args:
|
||||||
tts_sender = ""
|
tts_sender = ""
|
||||||
|
else:
|
||||||
|
tts_sender = request.args['tts_sender']
|
||||||
if 'tts_text' not in request.args:
|
if 'tts_text' not in request.args:
|
||||||
return flask.make_response('{\"text\":"Argument \'tts_text\' not in request"}', 400)
|
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__':
|
if __name__ == '__main__':
|
||||||
init()
|
#init()
|
||||||
api.run(host='0.0.0.0', port=93986)
|
api.run(host='0.0.0.0', port=40085)
|
||||||
Loading…
Reference in New Issue
Block a user