Stricter timing for lyrebird - quicker timeout = less waiting

This commit is contained in:
Ruben van de Ven 2019-08-23 10:07:10 +02:00
parent 0222c34d5c
commit f135520c87
2 changed files with 8 additions and 1 deletions

View file

@ -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()

View file

@ -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"