From f135520c8770ad29a88d9c4a10553b02615be27f Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 23 Aug 2019 10:07:10 +0200 Subject: [PATCH] Stricter timing for lyrebird - quicker timeout = less waiting --- hugvey/voice.py | 7 ++++++- server_config.yml | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hugvey/voice.py b/hugvey/voice.py index f0cb6d4..5588fe6 100644 --- a/hugvey/voice.py +++ b/hugvey/voice.py @@ -103,10 +103,15 @@ class LyrebirdVoiceFetcher(VoiceFetcher): method="POST", url="https://avatar.lyrebird.ai/api/v0/generate", body=json.dumps({"text": text}), - headers={"authorization": f"Bearer {self.config['token']}"} + headers={"authorization": f"Bearer {self.config['token']}"}, + connect_timeout=self.config['connect_timeout'] if 'connect_timeout' in self.config else 15.0, + request_timeout=self.config['request_timeout'] if 'request_timeout' in self.config else 18., ) + try: + logger.debug(f"Fetch Lyrebird voice file: POST {request.url} body: {request.body}") response = await http_client.fetch(request) + logger.debug(f"Got Lyrebird voice file in {response.request_time:.3}s") except Exception as e: logger.critical(f"Exception when getting Lyrebird voice file: POST {request.url} body: {request.body}") http_client.close() diff --git a/server_config.yml b/server_config.yml index f579c27..fc9d76e 100644 --- a/server_config.yml +++ b/server_config.yml @@ -15,6 +15,8 @@ languages: file: story_en.json type: "lyrebird" token: "LB_TOKEN" + connect_timeout: 3 + request_timeout: 5 - code: de-DE file: story_de.json type: "ms"