From e6c79b2a1c3493caf235502e5fcc2a66f848408d Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Fri, 14 Mar 2025 13:29:30 -0700 Subject: [PATCH] Update transcribe.php --- .../resources/functions/transcribe.php | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/email_queue/resources/functions/transcribe.php b/app/email_queue/resources/functions/transcribe.php index c93a0fccab..a954401530 100644 --- a/app/email_queue/resources/functions/transcribe.php +++ b/app/email_queue/resources/functions/transcribe.php @@ -9,16 +9,16 @@ if (!function_exists('transcribe')) { } //get the email queue settings - $setting = new settings(['category' => 'voicemail']); + $settings = new settings(['category' => 'voicemail']); //transcription variables - $transcribe_provider = $setting->get('voicemail', 'transcribe_provider'); - $transcribe_language = $setting->get('voicemail', 'transcribe_language'); + $transcribe_provider = $settings->get('voicemail', 'transcribe_provider'); + $transcribe_language = $settings->get('voicemail', 'transcribe_language'); //transcribe - watson if ($transcribe_provider == 'watson') { - $api_key = $setting->get('voicemail', 'watson_key'); - $api_url = $setting->get('voicemail', 'watson_url'); + $api_key = $settings->get('voicemail', 'watson_key'); + $api_url = $settings->get('voicemail', 'watson_url'); if ($file_extension == "mp3") { $content_type = 'audio/mp3'; @@ -29,7 +29,7 @@ if (!function_exists('transcribe')) { if (isset($api_key) && $api_key != '') { //start output buffer - ob_start(); + ob_start(); $out = fopen('php://output', 'w'); //create the curl resource @@ -118,11 +118,11 @@ if (!function_exists('transcribe')) { //transcribe - google if ($transcribe_provider == 'google') { - $api_key = $setting->get('voicemail', 'google_key'); - $api_url = $setting->get('voicemail', 'google_url'); - $application_credentials = $setting->get('voicemail', 'google_application_credentials'); - $transcribe_language = $setting->get('voicemail', 'transcribe_language'); - $transcribe_alternate_language = $setting->get('voicemail', 'transcribe_alternate_language'); + $api_key = $settings->get('voicemail', 'google_key'); + $api_url = $settings->get('voicemail', 'google_url'); + $application_credentials = $settings->get('voicemail', 'google_application_credentials'); + $transcribe_language = $settings->get('voicemail', 'transcribe_language'); + $transcribe_alternate_language = $settings->get('voicemail', 'transcribe_alternate_language'); if (!isset($transcribe_language) && empty($transcribe_language)) { $transcribe_language = 'en-US'; @@ -136,7 +136,7 @@ if (!function_exists('transcribe')) { if ($file_extension == "wav") { $content_type = 'audio/wav'; } - + //version 1 if (substr($api_url, 0, 32) == 'https://speech.googleapis.com/v1') { if (isset($api_key) && $api_key != '') { @@ -195,8 +195,8 @@ if (!function_exists('transcribe')) { //transcribe - azure if ($transcribe_provider == 'azure') { - $api_key = $setting->get('voicemail', 'azure_key'); - $api_url = $setting->get('voicemail', 'azure_server_region'); + $api_key = $settings->get('voicemail', 'azure_key'); + $api_url = $settings->get('voicemail', 'azure_server_region'); if (empty($transcribe_language)) { $transcribe_language = 'en-US'; @@ -241,8 +241,8 @@ if (!function_exists('transcribe')) { // transcribe - custom // Works with self-hostable transcription service at https://github.com/AccelerateNetworks/an-transcriptions if ($transcribe_provider == 'custom') { - $api_key = $setting->get('voicemail', 'api_key'); - $api_url = $setting->get('voicemail', 'transcription_server'); + $api_key = $settings->get('voicemail', 'api_key'); + $api_url = $settings->get('voicemail', 'transcription_server'); if (empty($transcribe_language)) { $transcribe_language = 'en-US'; @@ -322,9 +322,9 @@ if (!function_exists('transcribe')) { // openai_url // openai_model if ($transcribe_provider == 'openai') { - $api_key = $setting->get('voicemail', 'openai_key'); - $api_url = $setting->get('voicemail', 'openai_url'); - $api_voice_model = $setting->get('voicemail', 'openai_model'); + $api_key = $settings->get('voicemail', 'openai_key'); + $api_url = $settings->get('voicemail', 'openai_url'); + $api_voice_model = $settings->get('voicemail', 'openai_model'); if (empty($api_url)) { $api_url = "https://api.openai.com/v1/audio/transcriptions"; @@ -339,7 +339,7 @@ if (!function_exists('transcribe')) { $full_file_name = $file_path.'/'.$file_name ; //start output buffer - ob_start(); + ob_start(); $out = fopen('php://output', 'w'); //create the curl resource @@ -366,7 +366,7 @@ if (!function_exists('transcribe')) { //execute the curl with the options $http_content = curl_exec($ch); - + //return the error if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); @@ -380,9 +380,9 @@ if (!function_exists('transcribe')) { $debug = ob_get_clean(); echo $debug; - + $ob = json_decode($http_content, true); - + $message = $ob['text']; return array( 'provider' => $transcribe_provider, @@ -396,5 +396,5 @@ if (!function_exists('transcribe')) { } } - + ?>