Skip to content

Commit

Permalink
Removed dependency to tektrain_api, fixed elsa yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
etsardou authored and klpanagi committed Dec 14, 2020
1 parent 9a8b36a commit 46c446d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
1 change: 1 addition & 0 deletions configurations/elsa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ robots:
-
orientation: 0
place: FRONT
hz: 1
sensor_configuration:
framerate: 30
width: 640
Expand Down
15 changes: 15 additions & 0 deletions stream_simulator/simulator/controller_speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ def on_goal_speak(self, goalh):
self.blocked = False
return ret

def google_speak(self, language = None, texts = None, volume = None):
from google.cloud import texttospeech
self.voice = texttospeech.VoiceSelectionParams(\
language_code = language,\
ssml_gender = texttospeech.SsmlVoiceGender.FEMALE)

synthesis_input = texttospeech.SynthesisInput(text = texts)
response = self.client.synthesize_speech(input = synthesis_input, voice = self.voice, audio_config = self.audio_config)

self.speaker.volume = volume
self.speaker.async_write(response.audio_content, file_flag=False)
while self.speaker.playing:
print("Speaking...")
time.sleep(0.1)

def on_goal_play(self, goalh):
self.logger.info("{} play started".format(self.name))
if self.info["enabled"] == False:
Expand Down
46 changes: 27 additions & 19 deletions stream_simulator/simulator/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ def start(self):
self.robot.start()
self.logger.warning("Simulation started")
if self.robot.world['robots'][0]['mode'] == 'real' and self.robot.world['robots'][0]['speak_mode'] == "google":
from r4a_apis.robot_api import RobotAPI
from r4a_apis.google_api import GoogleAPI, GoogleLanguages
import os
from r4a_apis.utilities import InputMessage, OutputMessage, TekException, Languages

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/home/pi/google_ttsp.json"

self.logger.debug('main', "TestGoogleApi_text2Speech")
self.rapi = RobotAPI(logger = self.logger)
self.gapi = GoogleAPI(memory = self.rapi.memory, logger = self.logger)
InputMessage.logger = self.logger
OutputMessage.logger = self.logger
TekException.logger = self.logger
# from r4a_apis.robot_api import RobotAPI
# from r4a_apis.google_api import GoogleAPI, GoogleLanguages
# import os
# from r4a_apis.utilities import InputMessage, OutputMessage, TekException, Languages
#
# os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/home/pi/google_ttsp.json"
#
# self.logger.debug('main', "TestGoogleApi_text2Speech")
# self.rapi = RobotAPI(logger = self.logger)
# self.gapi = GoogleAPI(memory = self.rapi.memory, logger = self.logger)
# InputMessage.logger = self.logger
# OutputMessage.logger = self.logger
# TekException.logger = self.logger

# Wait for rhasspy
from derp_me.client import DerpMeClient
Expand All @@ -123,9 +123,17 @@ def start(self):
self.logger.warning("Rhasspy is up!")
rhasspy_ok = True

self.rapi.speak(InputMessage({
'device_id': "id_0",
'texts': ['Η συσκευή σας είναι έτοιμη προς χρήση!'],
'language': Languages.EL,
'volume': 50
}))
# ell
# Get the speaker
sp_con = None
for c in self.robot.controllers:
if "speaker" in c:
sp_con = self.robot.controllers[c]
break

if sp_con != None:
sp_con.google_speak(
language="el",
texts='Η συσκευή σας είναι έτοιμη προς χρήση!',
volume=50
)

0 comments on commit 46c446d

Please sign in to comment.