diff --git a/epub_to_audiobook.py b/epub_to_audiobook.py index 0bef826..6a0597a 100644 --- a/epub_to_audiobook.py +++ b/epub_to_audiobook.py @@ -123,7 +123,9 @@ def auto_renew_access_token(self) -> str: def get_access_token(self) -> str: for retry in range(MAX_RETRIES): try: + logger.info("Getting new access token") response = requests.post(self.TOKEN_URL, headers=self.TOKEN_HEADERS) + response.raise_for_status() # Will raise HTTPError for 4XX or 5XX status access_token = str(response.text) logger.info("Got new access token") return access_token @@ -176,9 +178,12 @@ def text_to_speech( "User-Agent": "Python", } try: + logger.info("Sending request to Azure TTS, data length: " + str(len(ssml))) response = requests.post( self.TTS_URL, headers=headers, data=ssml.encode("utf-8") ) + response.raise_for_status() # Will raise HTTPError for 4XX or 5XX status + logger.info("Got response from Azure TTS, response length: " + str(len(response.content))) audio_segments.append(io.BytesIO(response.content)) break except requests.exceptions.RequestException as e: