Ver Fonte

Allow defining a custom api_url for OpenAi

FusionPBX há 10 meses atrás
pai
commit
e3b6991267
1 ficheiros alterados com 4 adições e 5 exclusões
  1. 4 5
      resources/classes/speech_openai.php

+ 4 - 5
resources/classes/speech_openai.php

@@ -13,6 +13,7 @@ if (!class_exists('ai_openai')) {
 		 * declare private variables
 		 */
 		private $api_key;
+		private $api_url;
 		private $path;
 		private $filename;
 		private $format;
@@ -27,6 +28,7 @@ if (!class_exists('ai_openai')) {
 
 			//build the setting object and get the recording path
 			$this->api_key = $settings->get('speech', 'api_key');
+			$this->api_url = $settings->get('speech', 'api_url', '');
 
 		}
 
@@ -153,9 +155,6 @@ if (!class_exists('ai_openai')) {
 		 */
 		public function speech() : bool {
 
-			// set the request URL
-			$url = 'https://api.openai.com/v1/audio/speech';
-
 			// set the request headers
 			$headers = [
 				'Authorization: Bearer ' . $this->api_key,
@@ -175,7 +174,7 @@ if (!class_exists('ai_openai')) {
 			}
 
 			// initialize curl handle
-			$ch = curl_init($url);
+			$ch = curl_init($this->api_url);
 
 			// set the curl options
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -216,4 +215,4 @@ if (!class_exists('ai_openai')) {
 	}
 }
 
-?>
+?>