various little improvements
This commit is contained in:
parent
3aae72333b
commit
c23390cb79
@ -37,9 +37,11 @@ class Skill:
|
|||||||
for key, val in data.items():
|
for key, val in data.items():
|
||||||
if "{{" + key + "}}" in random_line:
|
if "{{" + key + "}}" in random_line:
|
||||||
|
|
||||||
|
# TODO: replace when found a better TTS engine for french
|
||||||
# as the french tts don't support float in sentence, convert it to an integer
|
# as the french tts don't support float in sentence, convert it to an integer
|
||||||
if is_float(val):
|
if is_float(val):
|
||||||
val = str(int(float(val)))
|
# val = str(int(float(val))) # convert a float to integer
|
||||||
|
val = str(val).split(".")[0] + " virgule " + str(val).split(".")[1]
|
||||||
|
|
||||||
random_line = random_line.replace("{{" + key + "}}", val)
|
random_line = random_line.replace("{{" + key + "}}", val)
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ from jarvis.utils import config_utils
|
|||||||
|
|
||||||
def speak(sentence, client_ip, client_port):
|
def speak(sentence, client_ip, client_port):
|
||||||
raw_audio_bytes = get_audio_from_sentence(sentence)
|
raw_audio_bytes = get_audio_from_sentence(sentence)
|
||||||
|
if raw_audio_bytes is None:
|
||||||
|
return "Error, audio not valid!"
|
||||||
|
|
||||||
play_audio_on_client(raw_audio_bytes, client_ip, client_port)
|
play_audio_on_client(raw_audio_bytes, client_ip, client_port)
|
||||||
|
|
||||||
|
|
||||||
@ -20,8 +23,12 @@ def get_audio_from_sentence(sentence):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# TODO : add support for external opentts server
|
# TODO : add support for external opentts server
|
||||||
|
try:
|
||||||
response = requests.get('http://localhost:5500/api/tts', headers=headers, params=params)
|
response = requests.get('http://localhost:5500/api/tts', headers=headers, params=params)
|
||||||
return response.content
|
return response.content
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
print("Error connecting to Open TTS server")
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def play_audio_on_client(raw_audio_bytes, client_ip, client_port):
|
def play_audio_on_client(raw_audio_bytes, client_ip, client_port):
|
||||||
@ -29,7 +36,6 @@ def play_audio_on_client(raw_audio_bytes, client_ip, client_port):
|
|||||||
|
|
||||||
headers = CaseInsensitiveDict()
|
headers = CaseInsensitiveDict()
|
||||||
headers["Content-Type"] = "text/xml; charset=utf8"
|
headers["Content-Type"] = "text/xml; charset=utf8"
|
||||||
# headers["Authorization"] = config_utils.get_in_config("API_KEY")
|
|
||||||
|
|
||||||
response = requests.post(url_service,
|
response = requests.post(url_service,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
|
Reference in New Issue
Block a user