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
parent
14d3ecaae7
commit
0efa0d1185
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue