mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2025-12-19 08:47:44 +00:00
env variable for tts stream connection timeout (#114)
* env variable for tts stream connection timeout Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * env variable for tts stream connection timeout Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * env variable for tts stream connection timeout Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> --------- Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>
This commit is contained in:
@@ -64,6 +64,27 @@ std::string secondsToMillisecondsString(double seconds) {
|
|||||||
return std::to_string(milliseconds_long);
|
return std::to_string(milliseconds_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string getEnvVar(const std::string& varName) {
|
||||||
|
const char* val = std::getenv(varName.c_str());
|
||||||
|
return val ? std::string(val) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getConnectionTimeout() {
|
||||||
|
std::string connectTimeoutStr = getEnvVar("CUSTOM_TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
|
||||||
|
if (connectTimeoutStr.empty()) {
|
||||||
|
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
long connectTimeout = 10L;
|
||||||
|
|
||||||
|
if (!connectTimeoutStr.empty()) {
|
||||||
|
connectTimeout = std::stol(connectTimeoutStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
static CURL* createEasyHandle(void) {
|
static CURL* createEasyHandle(void) {
|
||||||
CURL* easy = curl_easy_init();
|
CURL* easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
@@ -76,7 +97,7 @@ static CURL* createEasyHandle(void) {
|
|||||||
|
|
||||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 10L);
|
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||||
|
|
||||||
return easy ;
|
return easy ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,27 @@ std::string secondsToMillisecondsString(double seconds) {
|
|||||||
return std::to_string(milliseconds_long);
|
return std::to_string(milliseconds_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string getEnvVar(const std::string& varName) {
|
||||||
|
const char* val = std::getenv(varName.c_str());
|
||||||
|
return val ? std::string(val) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getConnectionTimeout() {
|
||||||
|
std::string connectTimeoutStr = getEnvVar("DEEPGRAM_TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
|
||||||
|
if (connectTimeoutStr.empty()) {
|
||||||
|
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
long connectTimeout = 10L;
|
||||||
|
|
||||||
|
if (!connectTimeoutStr.empty()) {
|
||||||
|
connectTimeout = std::stol(connectTimeoutStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
static CURL* createEasyHandle(void) {
|
static CURL* createEasyHandle(void) {
|
||||||
CURL* easy = curl_easy_init();
|
CURL* easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
@@ -77,7 +98,7 @@ static CURL* createEasyHandle(void) {
|
|||||||
|
|
||||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 10L);
|
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||||
|
|
||||||
return easy ;
|
return easy ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,27 @@ int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo_t *g) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string getEnvVar(const std::string& varName) {
|
||||||
|
const char* val = std::getenv(varName.c_str());
|
||||||
|
return val ? std::string(val) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getConnectionTimeout() {
|
||||||
|
std::string connectTimeoutStr = getEnvVar("ELEVENLABS_TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
|
||||||
|
if (connectTimeoutStr.empty()) {
|
||||||
|
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
long connectTimeout = 10L;
|
||||||
|
|
||||||
|
if (!connectTimeoutStr.empty()) {
|
||||||
|
connectTimeout = std::stol(connectTimeoutStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
static CURL* createEasyHandle(void) {
|
static CURL* createEasyHandle(void) {
|
||||||
CURL* easy = curl_easy_init();
|
CURL* easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
@@ -180,7 +201,7 @@ static CURL* createEasyHandle(void) {
|
|||||||
|
|
||||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 10L);
|
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||||
|
|
||||||
return easy ;
|
return easy ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,27 @@ std::string secondsToMillisecondsString(double seconds) {
|
|||||||
return std::to_string(milliseconds_long);
|
return std::to_string(milliseconds_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string getEnvVar(const std::string& varName) {
|
||||||
|
const char* val = std::getenv(varName.c_str());
|
||||||
|
return val ? std::string(val) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getConnectionTimeout() {
|
||||||
|
std::string connectTimeoutStr = getEnvVar("PLAYHT_TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
|
||||||
|
if (connectTimeoutStr.empty()) {
|
||||||
|
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
long connectTimeout = 20L;
|
||||||
|
|
||||||
|
if (!connectTimeoutStr.empty()) {
|
||||||
|
connectTimeout = std::stol(connectTimeoutStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
static CURL* createEasyHandle(void) {
|
static CURL* createEasyHandle(void) {
|
||||||
CURL* easy = curl_easy_init();
|
CURL* easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
@@ -77,7 +98,7 @@ static CURL* createEasyHandle(void) {
|
|||||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||||
//For long text, PlayHT took more than 20 seconds to complete the download.
|
//For long text, PlayHT took more than 20 seconds to complete the download.
|
||||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 60L);
|
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||||
|
|
||||||
return easy ;
|
return easy ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,27 @@ std::string secondsToMillisecondsString(double seconds) {
|
|||||||
return std::to_string(milliseconds_long);
|
return std::to_string(milliseconds_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string getEnvVar(const std::string& varName) {
|
||||||
|
const char* val = std::getenv(varName.c_str());
|
||||||
|
return val ? std::string(val) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getConnectionTimeout() {
|
||||||
|
std::string connectTimeoutStr = getEnvVar("RIMELABS_TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
|
||||||
|
if (connectTimeoutStr.empty()) {
|
||||||
|
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
long connectTimeout = 10L;
|
||||||
|
|
||||||
|
if (!connectTimeoutStr.empty()) {
|
||||||
|
connectTimeout = std::stol(connectTimeoutStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
static CURL* createEasyHandle(void) {
|
static CURL* createEasyHandle(void) {
|
||||||
CURL* easy = curl_easy_init();
|
CURL* easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
@@ -78,7 +99,7 @@ static CURL* createEasyHandle(void) {
|
|||||||
|
|
||||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 10L);
|
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||||
|
|
||||||
return easy ;
|
return easy ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,27 @@ std::string secondsToMillisecondsString(double seconds) {
|
|||||||
return std::to_string(milliseconds_long);
|
return std::to_string(milliseconds_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string getEnvVar(const std::string& varName) {
|
||||||
|
const char* val = std::getenv(varName.c_str());
|
||||||
|
return val ? std::string(val) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getConnectionTimeout() {
|
||||||
|
std::string connectTimeoutStr = getEnvVar("VERBIO_TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
|
||||||
|
if (connectTimeoutStr.empty()) {
|
||||||
|
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
long connectTimeout = 10L;
|
||||||
|
|
||||||
|
if (!connectTimeoutStr.empty()) {
|
||||||
|
connectTimeout = std::stol(connectTimeoutStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
static CURL* createEasyHandle(void) {
|
static CURL* createEasyHandle(void) {
|
||||||
CURL* easy = curl_easy_init();
|
CURL* easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
@@ -77,7 +98,7 @@ static CURL* createEasyHandle(void) {
|
|||||||
|
|
||||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 10L);
|
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||||
|
|
||||||
return easy ;
|
return easy ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,27 @@ std::string secondsToMillisecondsString(double seconds) {
|
|||||||
return std::to_string(milliseconds_long);
|
return std::to_string(milliseconds_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string getEnvVar(const std::string& varName) {
|
||||||
|
const char* val = std::getenv(varName.c_str());
|
||||||
|
return val ? std::string(val) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static long getConnectionTimeout() {
|
||||||
|
std::string connectTimeoutStr = getEnvVar("WHISPER_TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
|
||||||
|
if (connectTimeoutStr.empty()) {
|
||||||
|
connectTimeoutStr = getEnvVar("TTS_CURL_CONNECT_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
long connectTimeout = 10L;
|
||||||
|
|
||||||
|
if (!connectTimeoutStr.empty()) {
|
||||||
|
connectTimeout = std::stol(connectTimeoutStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
static CURL* createEasyHandle(void) {
|
static CURL* createEasyHandle(void) {
|
||||||
CURL* easy = curl_easy_init();
|
CURL* easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
@@ -76,7 +97,7 @@ static CURL* createEasyHandle(void) {
|
|||||||
|
|
||||||
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
// set connect timeout to 3 seconds and total timeout to 109 seconds
|
||||||
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS, 3000L);
|
||||||
curl_easy_setopt(easy, CURLOPT_TIMEOUT, 10L);
|
curl_easy_setopt(easy, CURLOPT_TIMEOUT, getConnectionTimeout());
|
||||||
|
|
||||||
return easy ;
|
return easy ;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user