Extended TTS generation timeout in Gradio
extended the timeout to await a TTS generation response, just to help with Google colab
This commit is contained in:
1 parent
6f75ab9f60
commit
6f4bec7ab2
1 file changed
+30
-23
@@ -1408,7 +1408,7 @@ if gradio_enabled == True:
|
|||||||
# Restart the subprocess
|
# Restart the subprocess
|
||||||
restart_subprocess()
|
restart_subprocess()
|
||||||
# Wait for the engine to be ready with error handling and retries
|
# Wait for the engine to be ready with error handling and retries
|
||||||
max_retries = 140
|
max_retries = 80
|
||||||
retry_delay = 1 # seconds
|
retry_delay = 1 # seconds
|
||||||
retries = 0
|
retries = 0
|
||||||
while retries < max_retries:
|
while retries < max_retries:
|
||||||
@@ -1654,30 +1654,37 @@ if gradio_enabled == True:
|
|||||||
"repetition_penalty": str(gen_repetition),
|
"repetition_penalty": str(gen_repetition),
|
||||||
}
|
}
|
||||||
#print(f"Debug: Generate request param:", data) if params["debug_tts"] else None
|
#print(f"Debug: Generate request param:", data) if params["debug_tts"] else None
|
||||||
try:
|
max_retries = 180 #3 minutes
|
||||||
response = requests.post(api_url, data=data)
|
retry_delay = 1 # seconds
|
||||||
response.raise_for_status() # Raise an exception for 4xx or 5xx status codes
|
retries = 0
|
||||||
result = response.json()
|
while retries < max_retries:
|
||||||
if gen_autopl == "true":
|
try:
|
||||||
return None, str("TTS Audio Generated (Played remotely)")
|
response = requests.post(api_url, data=data, timeout=60)
|
||||||
else:
|
response.raise_for_status() # Raise an exception for 4xx or 5xx status codes
|
||||||
if params["api_def"]["api_use_legacy_api"]:
|
result = response.json()
|
||||||
return result['output_file_url'], str("TTS Audio Generated")
|
if gen_autopl == "true":
|
||||||
|
return None, str("TTS Audio Generated (Played remotely)")
|
||||||
else:
|
else:
|
||||||
# Set the protocol type
|
if params["api_def"]["api_use_legacy_api"]:
|
||||||
protocol = "http://" # or "https://" if using HTTPS
|
return result['output_file_url'], str("TTS Audio Generated")
|
||||||
# Prepend the URL and PORT to the output_file_url
|
|
||||||
if running_on_google_colab:
|
|
||||||
output_file_url = f"{tunnel_url_1}{result['output_file_url']}"
|
|
||||||
else:
|
else:
|
||||||
output_file_url = f"{protocol}{my_current_url}{result['output_file_url']}"
|
# Set the protocol type
|
||||||
return output_file_url, str("TTS Audio Generated")
|
protocol = "http://" # or "https://" if using HTTPS
|
||||||
except requests.exceptions.RequestException as e:
|
# Prepend the URL and PORT to the output_file_url
|
||||||
error_message = "An error occurred. Please see console output."
|
if running_on_google_colab:
|
||||||
print(f"[{branding}TTS] \033[91mError:\033[0m {error_message}")
|
output_file_url = f"{tunnel_url_1}{result['output_file_url']}"
|
||||||
print(f"[{branding}TTS] \033[91mError Details:\033[0m {str(e)}")
|
else:
|
||||||
# Handle the error or return an appropriate error message
|
output_file_url = f"{protocol}{my_current_url}{result['output_file_url']}"
|
||||||
return None, str(error_message)
|
return output_file_url, str("TTS Audio Generated")
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
retries += 1
|
||||||
|
if retries == max_retries:
|
||||||
|
error_message = "An error occurred. Please see console output."
|
||||||
|
print(f"[{branding}TTS] \033[91mError:\033[0m {error_message}")
|
||||||
|
print(f"[{branding}TTS] \033[91mError Details:\033[0m {str(e)}")
|
||||||
|
# Handle the error or return an appropriate error message
|
||||||
|
return None, str(error_message)
|
||||||
|
time.sleep(retry_delay)
|
||||||
|
|
||||||
def alltalk_gradio():
|
def alltalk_gradio():
|
||||||
global languages_list, at_settings
|
global languages_list, at_settings
|
||||||
|
|||||||
Reference in new issue
Block a user