Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

lunes, 18 de noviembre de 2024

domingo, 10 de noviembre de 2024

agi commands



#!/bin/php 
<?php
$agent=7000;


$timeout=12;




echo "EXEC Dial \"PJSIP/$agent,$timeout\"\n";




//echo "EXEC G

echo "EXEC Dial \"PJSIP/6000,10\"\n";


echo "EXEC Goto \"internal,100,1\"\n";



echo "EXEC Playback goodbye\n";
 

echo "SET VARIABLE $variableName \"$variableValue\"\n";

echo "EXEC  saydigits 0133";

echo "EXEC Verbose \"TEST VAR IS :  $var \"\n";

?>

miércoles, 30 de octubre de 2024

Real Time Transcription

 https://www.youtube.com/watch?v=ypcsB5Ld6zw&


https://community.asterisk.org/t/is-it-possible-to-transcribe-live-calls-with-asterisk/98992/7


https://platform.openai.com/docs/guides/audio/next-steps


https://platform.openai.com/docs/guides/realtime/quickstart


https://openai.com/index/introducing-the-realtime-api/

miércoles, 16 de octubre de 2024

pjsip example template

 https://docs.asterisk.org/Configuration/Channel-Drivers/SIP/Configuring-res_pjsip/res_pjsip-Configuration-Examples/

lunes, 7 de octubre de 2024

calling script

 <?php

//error_reporting(E_ALL);

//ini_set('display_errors', 1);

header('Content-Type: application/json');

echo json_encode($_REQUEST, JSON_PRETTY_PRINT);


$timeout=100;

$host="127.0.0.1";

$port=5038;


$src = preg_replace('/\s+/', '', $_GET['src']);

$dst = preg_replace('/\s+/', '', $_GET['dst']);

$trunk = preg_replace('/\s+/', '', $_GET['trunk']);

$cid = preg_replace('/\s+/', '', $_GET['cid']);

$id = preg_replace('/\s+/', '', $_GET['id']);


$socket = fsockopen("$host","$port", $errno, $errstr, 10);

      if (!$socket){

        echo "$errstr ($errno)\n";

        }else{

            fputs($socket, "Action: Login\r\n");

            fputs($socket, "UserName: admin\r\n");

            fputs($socket, "Secret: oy13xtq7h\r\n\r\n");


          $wrets=fgets($socket,128);

       //       echo $wrets;

              fputs($socket, "Action: Originate\r\n" );

              fputs($socket, "Channel: Local/$src@internal\r\n" );

              fputs($socket, "Exten: $dst\r\n" );

               fputs($socket, "Context: internal\r\n" );

               fputs($socket, "Priority: 1\r\n" );

               fputs($socket, "CallerID: $cid\r\n" );

                fputs($socket, "Variable: __ext=$ext\r\n" );

               fputs($socket, "Variable: __dest=$dest\r\n" );

               fputs($socket, "Variable: __cid=$callerid\r\n" );

             fputs($socket, "Async: yes\r\n\r\n" );   

        fputs($socket, "Action: Logoff\r\n\r\n");

           while (!feof($socket)){

 $result=fgets($socket);

 $result= stristr($result,"$number");

 $d=strlen($result);




}


fclose($socket);

 }


?>


;;;;;;;;;;;;;;;;
exten=>_*x.,1,Noop(${EXTEN})
same=>n,Agi(/root/vars.py,${EXTEN})
same=>n,Noop(------${prefix} ${cid} ${dst}---)
;same=>n,Set(CALLERID(num)=${cid})

same => n,ExecIf($[${LEN(${cid})} > 0]?Set(CALLERID(num)=${cid}):)

same=>n,goto(internal,**${prefix}${dst},1)
same=>n,hangup()
---------
nano /root/vars.py   
                                                                        
#!/usr/bin/env python3
import sys
number=sys.argv[1]

e=number.split('*')

e=[int(a) for a in e if len(a)>0]

cid='cid'

dst='dst'
prefix='prefix'

print(f'SET VARIABLE {prefix} "{e[0]}"\n')

print(f'SET VARIABLE {cid} "{e[1]}"\n')

print(f'SET VARIABLE {dst} "{e[2]}"\n')



.....
[usa]
exten=>_**1.,1,Gosub(monitor,${EXTEN:3},1)
same=>n,Dial(PJSIP/zadarma/sip:+${EXTEN:3}@185.45.155.17:5060,,r)
same=>n,hangup()
exten=>h,1,Noop(${path}${STRFTIME(${EPOCH},,%Y-%m-%d_%H-%M-%S)}-${EXTEN}_${src}.wav)
same=>n,System(python3 /root/s3_recordings.py ${file})

[voipcloud]
exten=>_**4.,1,Gosub(monitor,${EXTEN:3},1)
same=>n,Set(CALLERID(num)=+61480039787)
same=>n,Dial(PJSIP/t1/sip:+${EXTEN:3}@sipm2.au.voipcloud.online:7060,,r)
same=>n,hangup()

exten=>h,1,Noop(${path}${STRFTIME(${EPOCH},,%Y-%m-%d_%H-%M-%S)}-${EXTEN}_${src}.wav)
same=>n,System(python3 /root/s3_recordings.py ${file})


sábado, 28 de septiembre de 2024

Python delay script for asterisk

 


#!/usr/bin/env python


import subprocess

import time

import sys


# Check if the caller argument is provided

if len(sys.argv) < 2:

    print("Usage: script.py <caller>")

    sys.exit(1)


caller = sys.argv[1]


i = 0

while i < 30:

    print(i)

    time.sleep(1)

    i += 1


# Run the command and capture the output

command = ['/usr/sbin/asterisk', '-x', 'channel redirect {} vc_lookup,100,play'.format(caller)]

try:

    result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    output, error = result.communicate()


    # Print the output

    print(output)

    if error:

print("Error:", error)


except Exception as e:

    print("An error occurred:", str(e))

lunes, 23 de septiembre de 2024

google tts asterisk using python virtual env

 [vaccine-rev]

exten=>100,1,Answer()

same=>n,Set(fname=${CHANNEL})

same=>n,agi(/var/www/html/google_tts/tts.py,${fname:4},"Total number of students registered with this telephone number.")

same=>n,playback(/var/www/html/google_tts/audios/${fname:4})

same=>n,Saynumber(3)

same=>n,agi(/var/www/html/google_tts/tts.py,${fname:4},"David is missing the following vaccines:")

same=>n,playback(/var/www/html/google_tts/audios/${fname:4})


same=>n,hangup()

---------
#!/var/www/html/google_tts/myenv/bin/python3

import os
import sys

import google.cloud.texttospeech as tts

# Set the path to your Google Cloud credentials
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/var/www/html/google_tts/voice.json"

def text_to_wav(voice_name: str, text: str):
    language_code = "-".join(voice_name.split("-")[:2])
    text_input = tts.SynthesisInput(text=text)
    voice_params = tts.VoiceSelectionParams(
        language_code=language_code, name=voice_name
    )

    # Set the audio configuration with 8000 Hz sample rate
    audio_config = tts.AudioConfig(
        audio_encoding=tts.AudioEncoding.LINEAR16,
        sample_rate_hertz=8000  # Set sample rate to 8000 Hz
    )

    client = tts.TextToSpeechClient()
    response = client.synthesize_speech(
        input=text_input,
        voice=voice_params,
        audio_config=audio_config,
    )

    # Change the path to save the file in the desired location
    filename = f"/var/www/html/google_tts/audios/{sys.argv[1]}.wav"  # Specify the desired save path
    with open(filename, "wb") as out:
        out.write(response.audio_content)
        print(f'Generated speech saved to "{filename}"')

# Ensure the command line argument is provided
if len(sys.argv) > 1:
    text_to_wav("en-US-Studio-O", sys.argv[2])


#######

(myenv) [root@freepbx google_tts]# pip list
Package                   Version
------------------------- ---------
cachetools                4.2.4
certifi                   2024.8.30
charset-normalizer        2.0.12
google-api-core           2.8.2
google-auth               2.22.0
google-cloud-texttospeech 2.11.1
googleapis-common-protos  1.56.3
grpcio                    1.48.2
grpcio-status             1.48.2
idna                      3.10
pip                       21.3.1
proto-plus                1.23.0
protobuf                  3.19.6
pyasn1                    0.5.1
pyasn1-modules            0.3.0
requests                  2.27.1
rsa                       4.9
setuptools                39.2.0
six                       1.16.0
urllib3                   1.26.20
(myenv) [root@freepbx google_tts]# pip freeze
cachetools==4.2.4
certifi==2024.8.30
charset-normalizer==2.0.12
google-api-core==2.8.2
google-auth==2.22.0
google-cloud-texttospeech==2.11.1
googleapis-common-protos==1.56.3
grpcio==1.48.2
grpcio-status==1.48.2
idna==3.10
proto-plus==1.23.0
protobuf==3.19.6
pyasn1==0.5.1
pyasn1-modules==0.3.0
requests==2.27.1
rsa==4.9
six==1.16.0
urllib3==1.26.20