From 33507661107d6ff9f588d96e9807794dd2ccb3e1 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Tue, 19 Jul 2022 15:49:07 +0200 Subject: [PATCH] Query for async synthesis result --- coqui/__init__.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/coqui/__init__.py b/coqui/__init__.py index 22fe56a..4a3fc47 100644 --- a/coqui/__init__.py +++ b/coqui/__init__.py @@ -1,5 +1,5 @@ """ A Python API and CLI to use Coqui services programmatically """ -__version__ = "0.0.5" +__version__ = "0.0.6" import asyncio from collections import namedtuple @@ -338,6 +338,18 @@ async def synthesize(self, voice_id, text, speed, name) -> Sample: } """ ) + query = gql( + """ + query Sample($id: String!) { + sample(id: $id) { + id + name + text + created_at + audio_url + } + } + """) try: result = await session.execute( mutation, @@ -358,7 +370,12 @@ async def synthesize(self, voice_id, text, speed, name) -> Sample: for err in result["errors"] ) raise SynthesisError(all_errors) - return Sample(**result["sample"]) + + sample = Sample(**result["sample"]) + while sample.audio_url is None: + result = await session.execute(query, variable_values={"id": sample.id}) + sample = Sample(**result["sample"]) + return sample @staticmethod async def download_file(url, f, chunk_size=5 * 2**20):