mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Call Recording Transcription multiple changes
- Use the new transcribe_queue class and method
- Move call recording transcription to xml_cdr_transcripts
- Remove transcribe_target table, keys and colum name
This commit is contained in:
@@ -199,7 +199,40 @@ class call_recordings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transcribes multiple call recordings.
|
* Add transcript to the xml_cdr_transcripts queue
|
||||||
|
*
|
||||||
|
* @param array $params contain domain_uuid, xml_cdr_uuid and call_direction, transcript_json, transcribe_summary
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function transcribe_queue($params) {
|
||||||
|
//set the global variables
|
||||||
|
global $database;
|
||||||
|
|
||||||
|
//define the array
|
||||||
|
$array = [];
|
||||||
|
|
||||||
|
//prepare the array with the transcript details
|
||||||
|
$array['xml_cdr_transcripts'][0]['xml_cdr_transcript_uuid'] = uuid();
|
||||||
|
$array['xml_cdr_transcripts'][0]['domain_uuid'] = $params['domain_uuid'];
|
||||||
|
$array['xml_cdr_transcripts'][0]['xml_cdr_uuid'] = $params['xml_cdr_uuid'];
|
||||||
|
$array['xml_cdr_transcripts'][0]['transcript_json'] = $params['transcribe_message'];
|
||||||
|
|
||||||
|
//add temporary permissions
|
||||||
|
$p = permissions::new();
|
||||||
|
$p->add('xml_cdr_transcript_add', 'temp');
|
||||||
|
|
||||||
|
//save the call recording transcript
|
||||||
|
$result = $this->database->save($array, false);
|
||||||
|
$result = $this->database->message;
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//remove the temporary permissions
|
||||||
|
$p->delete('xml_cdr_transcript_add', 'temp');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add one or more calls recordings to the transcribe queue.
|
||||||
*
|
*
|
||||||
* @param array $records An array of records to transcribe.
|
* @param array $records An array of records to transcribe.
|
||||||
*
|
*
|
||||||
@@ -233,7 +266,7 @@ class call_recordings {
|
|||||||
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||||
|
|
||||||
//get the call recording file name and path
|
//get the call recording file name and path
|
||||||
$sql = "select call_recording_name, call_recording_path ";
|
$sql = "select call_recording_name, call_recording_path, call_direction ";
|
||||||
$sql .= "from view_call_recordings ";
|
$sql .= "from view_call_recordings ";
|
||||||
$sql .= "where call_recording_uuid = :call_recording_uuid ";
|
$sql .= "where call_recording_uuid = :call_recording_uuid ";
|
||||||
$sql .= "and call_recording_transcription is null ";
|
$sql .= "and call_recording_transcription is null ";
|
||||||
@@ -244,19 +277,21 @@ class call_recordings {
|
|||||||
@sizeof($field) != 0 &&
|
@sizeof($field) != 0 &&
|
||||||
file_exists($field['call_recording_path'] . '/' . $field['call_recording_name'])
|
file_exists($field['call_recording_path'] . '/' . $field['call_recording_name'])
|
||||||
) {
|
) {
|
||||||
|
//prepare the paramaters
|
||||||
|
$params['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
|
$params['xml_cdr_uuid'] = $record['uuid'];
|
||||||
|
$params['call_direction'] = $field['call_direction'];
|
||||||
|
|
||||||
//add the recording to the transcribe queue
|
//add the recording to the transcribe queue
|
||||||
$array['transcribe_queue'][$x]['transcribe_queue_uuid'] = uuid();
|
$array['transcribe_queue'][$x]['transcribe_queue_uuid'] = $record['uuid'];
|
||||||
$array['transcribe_queue'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
$array['transcribe_queue'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
$array['transcribe_queue'][$x]['hostname'] = gethostname();
|
$array['transcribe_queue'][$x]['hostname'] = gethostname();
|
||||||
$array['transcribe_queue'][$x]['transcribe_status'] = 'pending';
|
$array['transcribe_queue'][$x]['transcribe_status'] = 'pending';
|
||||||
$array['transcribe_queue'][$x]['transcribe_application_name'] = 'call_recordings';
|
$array['transcribe_queue'][$x]['transcribe_app_class'] = 'call_recordings';
|
||||||
$array['transcribe_queue'][$x]['transcribe_application_uuid'] = '56165644-598d-4ed8-be01-d960bcb8ffed';
|
$array['transcribe_queue'][$x]['transcribe_app_method'] = 'transcribe_queue';
|
||||||
|
$array['transcribe_queue'][$x]['transcribe_app_params'] = json_encode($params);
|
||||||
$array['transcribe_queue'][$x]['transcribe_audio_path'] = $field['call_recording_path'];
|
$array['transcribe_queue'][$x]['transcribe_audio_path'] = $field['call_recording_path'];
|
||||||
$array['transcribe_queue'][$x]['transcribe_audio_name'] = $field['call_recording_name'];
|
$array['transcribe_queue'][$x]['transcribe_audio_name'] = $field['call_recording_name'];
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_table'] = 'xml_cdr';
|
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_key_name'] = 'xml_cdr_uuid';
|
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_key_uuid'] = $record['uuid'];
|
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_column_name'] = 'record_transcription';
|
|
||||||
|
|
||||||
//increment the id
|
//increment the id
|
||||||
$x++;
|
$x++;
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$view['name'] = "view_call_recordings";
|
$view['name'] = "view_call_recordings";
|
||||||
$view['version'] = "20250919";
|
$view['version'] = "20251210";
|
||||||
$view['description'] = "Show the call recordings details from the call detail records database.";
|
$view['description'] = "Show the call recordings details from the call detail records database.";
|
||||||
$view['sql'] = " select domain_uuid, xml_cdr_uuid as call_recording_uuid, \n";
|
$view['sql'] = " SELECT c.domain_uuid, c.xml_cdr_uuid AS call_recording_uuid, \n";
|
||||||
$view['sql'] .= " caller_id_name, caller_id_number, caller_destination, destination_number, \n";
|
$view['sql'] .= " caller_id_name, caller_id_number, caller_destination, destination_number, \n";
|
||||||
$view['sql'] .= " record_name as call_recording_name, record_path as call_recording_path, \n";
|
$view['sql'] .= " record_name AS call_recording_name, record_path AS call_recording_path, \n";
|
||||||
$view['sql'] .= " record_transcription as call_recording_transcription, \n";
|
$view['sql'] .= " t.transcript_json AS call_recording_transcription, \n";
|
||||||
$view['sql'] .= " duration as call_recording_length, start_stamp as call_recording_date, direction as call_direction \n";
|
$view['sql'] .= " record_transcription, \n";
|
||||||
$view['sql'] .= " from v_xml_cdr \n";
|
$view['sql'] .= " duration AS call_recording_length, start_stamp AS call_recording_date, direction AS call_direction \n";
|
||||||
$view['sql'] .= " where record_name is not null \n";
|
$view['sql'] .= " FROM v_xml_cdr as c, v_xml_cdr_transcripts as t \n";
|
||||||
$view['sql'] .= " and record_path is not null \n";
|
$view['sql'] .= " WHERE record_name IS NOT NULL \n";
|
||||||
$view['sql'] .= " order by start_stamp desc \n";
|
$view['sql'] .= " AND record_path is not null \n";
|
||||||
|
$view['sql'] .= " AND c.xml_cdr_uuid = t.xml_cdr_uuid \n";
|
||||||
|
$view['sql'] .= " ORDER BY start_stamp desc \n";
|
||||||
|
|||||||
@@ -1171,4 +1171,70 @@
|
|||||||
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
||||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
|
||||||
|
//schema details
|
||||||
|
$y++;
|
||||||
|
$apps[$x]['db'][$y]['table']['name'] = "v_xml_cdr_transcripts";
|
||||||
|
$apps[$x]['db'][$y]['table']['parent'] = "";
|
||||||
|
$z=0;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "xml_cdr_transcript_uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "xml_cdr_uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_xml_cdr";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transcript_json";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "jsonb";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transcript_summary";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_date";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_user";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "update_date";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
$z++;
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['name'] = "update_user";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
||||||
|
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -89,19 +89,21 @@
|
|||||||
!empty($record_path) && !empty($record_name) &&
|
!empty($record_path) && !empty($record_name) &&
|
||||||
file_exists($record_path.'/'.$record_name)) {
|
file_exists($record_path.'/'.$record_name)) {
|
||||||
|
|
||||||
|
//prepare the params
|
||||||
|
$params['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
|
$params['xml_cdr_uuid'] = $uuid;
|
||||||
|
$params['call_direction'] = $call_direction;
|
||||||
|
|
||||||
//add the recording to the transcribe queue
|
//add the recording to the transcribe queue
|
||||||
$array['transcribe_queue'][$x]['transcribe_queue_uuid'] = uuid();
|
$array['transcribe_queue'][$x]['transcribe_queue_uuid'] = uuid();
|
||||||
$array['transcribe_queue'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
$array['transcribe_queue'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
$array['transcribe_queue'][$x]['hostname'] = gethostname();
|
$array['transcribe_queue'][$x]['hostname'] = gethostname();
|
||||||
$array['transcribe_queue'][$x]['transcribe_status'] = 'pending';
|
$array['transcribe_queue'][$x]['transcribe_status'] = 'pending';
|
||||||
$array['transcribe_queue'][$x]['transcribe_application_name'] = 'call_recordings';
|
$array['transcribe_queue'][$x]['transcribe_app_class'] = 'call_recordings';
|
||||||
$array['transcribe_queue'][$x]['transcribe_application_uuid'] = '56165644-598d-4ed8-be01-d960bcb8ffed';
|
$array['transcribe_queue'][$x]['transcribe_app_method'] = 'transcribe';
|
||||||
|
$array['transcribe_queue'][$x]['transcribe_app_params'] = json_encode($params);
|
||||||
$array['transcribe_queue'][$x]['transcribe_audio_path'] = $record_path;
|
$array['transcribe_queue'][$x]['transcribe_audio_path'] = $record_path;
|
||||||
$array['transcribe_queue'][$x]['transcribe_audio_name'] = $record_name;
|
$array['transcribe_queue'][$x]['transcribe_audio_name'] = $record_name;
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_table'] = 'xml_cdr';
|
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_key_name'] = 'xml_cdr_uuid';
|
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_key_uuid'] = $uuid;
|
|
||||||
$array['transcribe_queue'][$x]['transcribe_target_column_name'] = 'record_transcription';
|
|
||||||
|
|
||||||
//add the checked rows
|
//add the checked rows
|
||||||
if (is_array($array) && @sizeof($array) != 0) {
|
if (is_array($array) && @sizeof($array) != 0) {
|
||||||
@@ -183,6 +185,25 @@
|
|||||||
unset($sql, $parameters, $row);
|
unset($sql, $parameters, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the cdr transcript from the database
|
||||||
|
//if (permission_exists('xml_cdr_call_log') && $call_log_enabled) {
|
||||||
|
$sql = "select * from v_xml_cdr_transcripts ";
|
||||||
|
if (permission_exists('xml_cdr_all')) {
|
||||||
|
$sql .= "where xml_cdr_uuid = :xml_cdr_uuid ";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql .= "where xml_cdr_uuid = :xml_cdr_uuid ";
|
||||||
|
$sql .= "and domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
}
|
||||||
|
$parameters['xml_cdr_uuid'] = $uuid;
|
||||||
|
$row = $database->select($sql, $parameters, 'row');
|
||||||
|
if (!empty($row) && is_array($row) && @sizeof($row) != 0) {
|
||||||
|
$transcript_json = trim($row["transcript_json"] ?? '');
|
||||||
|
}
|
||||||
|
unset($sql, $parameters, $row);
|
||||||
|
//}
|
||||||
|
|
||||||
//get the format
|
//get the format
|
||||||
if (!empty($xml_string)) {
|
if (!empty($xml_string)) {
|
||||||
$format = "xml";
|
$format = "xml";
|
||||||
@@ -372,7 +393,7 @@
|
|||||||
foreach ($transcription as $segment) {
|
foreach ($transcription as $segment) {
|
||||||
if ($previous_speaker != $segment['speaker']) {
|
if ($previous_speaker != $segment['speaker']) {
|
||||||
if ($i > 0) { $html .= "</div>\n"; }
|
if ($i > 0) { $html .= "</div>\n"; }
|
||||||
$speaker_class = $segment['speaker'] === 'A' ? 'message-bubble-em' : 'message-bubble-me';
|
$speaker_class = $segment['speaker'] === '0' ? 'message-bubble-em' : 'message-bubble-me';
|
||||||
$html .= "<div class='message-bubble {$speaker_class}'>";
|
$html .= "<div class='message-bubble {$speaker_class}'>";
|
||||||
}
|
}
|
||||||
//$html .= " <span class='time'>[{$segment['start']} - {$segment['end']}]</span>";
|
//$html .= " <span class='time'>[{$segment['start']} - {$segment['end']}]</span>";
|
||||||
@@ -634,7 +655,7 @@
|
|||||||
echo "</style>\n";
|
echo "</style>\n";
|
||||||
|
|
||||||
//transcription, if enabled
|
//transcription, if enabled
|
||||||
$transcription_array = json_decode($record_transcription, true);
|
$transcription_array = json_decode($transcript_json, true);
|
||||||
$record_transcription = $transcription_array['segments'];
|
$record_transcription = $transcription_array['segments'];
|
||||||
$record_transcription_html = conversational_html($record_transcription);
|
$record_transcription_html = conversational_html($record_transcription);
|
||||||
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($record_transcription)) {
|
if ($transcribe_enabled == 'true' && !empty($transcribe_engine) && !empty($record_transcription)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user