Replace print statements with logging.error

This commit replaces two print statements in the _speech method of the BrianSpeech class with a single call to logging.error. This will log error messages with more detail and make it easier to diagnose issues. The changes are backward compatible and should not affect the functionality of the code.
pull/2708/head
Ugo 2023-04-20 20:52:45 +03:00 committed by GitHub
parent 14d3ecaae7
commit 0efa0d1185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 9 deletions

View File

@ -1,12 +1,9 @@
""" Brian speech module for autogpt """
import os
import requests
import logging
from playsound import playsound
from autogpt.speech.base import VoiceBase
class BrianSpeech(VoiceBase):
"""Brian speech module for autogpt"""
@ -23,9 +20,7 @@ class BrianSpeech(VoiceBase):
Returns:
bool: True if the request was successful, False otherwise
"""
tts_url = (
f"https://api.streamelements.com/kappa/v2/speech?voice=Brian&text={text}"
)
tts_url = f"https://api.streamelements.com/kappa/v2/speech?voice=Brian&text={text}"
response = requests.get(tts_url)
if response.status_code == 200:
@ -35,6 +30,5 @@ class BrianSpeech(VoiceBase):
os.remove("speech.mp3")
return True
else:
print("Request failed with status code:", response.status_code)
print("Response content:", response.content)
logging.error("Request failed with status code: %s, response content: %s", response.status_code, response.content)
return False