domingo, 19 de febrero de 2023

google tts command

 /usr/bin/php /root/google_tts/google_tts_asterisk_es.php "Hola mi  nombre es Ambiorix" >/root/google_tts/audios/audio.txt && 

/usr/bin/php /root/google_tts/convert.php audio



/usr/bin/php /root/google_tts/google_tts_asterisk.php "Hello Ambiorix" >/root/google_tts/audios/audio.txt &&  /usr/bin/php /root/google_tts/convert.php audio

jueves, 9 de febrero de 2023

Sending SMS from csv

 


<?php


require __DIR__ . "/vendor/autoload.php";

 

use Telnyx\Api\ApiClient;

use Telnyx\Api\Message;


// Read the csv file

$file = fopen('file.csv', 'r');


// Set the api key

$telnyx = new ApiClient("YOUR_API_KEY");


while (($line = fgetcsv($file)) !== FALSE) {

    // Retrieve data from the csv

    $phoneNumber = $line[0];

    $message = $line[1];


    // Send the SMS message

    $message = Message::create([

        "from" => "+18881234567",

        "to" => $phoneNumber,

        "text" => $message

    ]);

    echo "\n Sent SMS to {$phoneNumber}: {$message->text}\n";

}


// Close the file

fclose($file);



?>


--------------------------------------------------------------------------------------------------------


This code assumes that the csv file contains data structured like this:

  Name, Phone Number

  John, +19998881234

  Sam, +14447778899


<?php

$csvFile = fopen('contactList.csv', 'r');

$telnyx = new Telnyx\Client('YOUR_TELNYX_API_KEY');


// Iterate over each row in the CSV file

while (($row = fgetcsv($csvFile)) !== FALSE) {

  // Set recipient name and number

  $name = $row[0];

  $number = $row[1];


  // Set message body

  $message = new Telnyx\SMSMessage(

    ["from" => "+15551234567",

     "to" => $number,

     "text" => "Hey, $name! Test message from Telnyx."]

  );


  // Send the message

  $response = $telnyx->SMS->messages->create($message);

}


fclose($csvFile);

?>

martes, 7 de febrero de 2023

google tts and speech api

 https://cloud.google.com/text-to-speech/docs/voices

https://cloud.google.com/speech-to-text/docs/speech-to-text-supported-languages

https://cloud.google.com/speech-to-text/docs/transcribe-api

https://cloud.google.com/text-to-speech/docs/libraries#client-libraries-usage-nodejs

https://cloud.google.com/text-to-speech


    1. Make sure billing is enabled for Speech-to-Text.
    2. Create and/or assign one or more service accounts to Speech-to-Text.
    3. Download a service account credential key.
  • Set your authentication environment variable.
  • (Optional) Create a new Google Cloud Storage bucket to store your audio data.


https://cloud.google.com/speech-to-text/docs/before-you-begin


miércoles, 1 de febrero de 2023

gpt php request

<?php

$url = "https://api.openai.com/v1/completions";


$data = array('prompt' => $argv[1],'max_tokens' =>10, 'model'=> 'text-davinci-003','max_tokens'=>4000,'temperature'=> 1.0);

$encodedData = json_encode($data);



//$data = array(\"param1\" => \"value1\",\"param2\" => \"value2\"\);



$headers = array('Content-Type: application/json','Authorization:Bearer my-key-sdLwvCv');


$curl = curl_init();

$data_string = urlencode(json_encode($data));



curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

curl_setopt($curl, CURLOPT_POST, 1);

//curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));

curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedData);



curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

curl_close($curl);

//echo $response;  //uncoment this line if you need log info

$object=json_decode($response);

$array = (array) $object;


$response=(array)$array['choices'][0];

echo  $response['text'];

echo  "\n";

?>

viernes, 27 de enero de 2023

curl flowroute API

 <?php

$username="ambiorixg12";

$password="d9914a2s1111refadfe43";

$url = "https://api.flowroute.com/v2.1/messages";

$data = array(

    "to" => "12057143489",

    "from" => "18452375521",

    "body" => "jane_mc@gmail.com",

);

$encodedData = json_encode($data);

$curl = curl_init($url);

$data_string = urlencode(json_encode($data));

curl_setopt($curl, CURLOPT_USERPWD, $username . ":".$password);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");

curl_setopt( $curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedData);

$result = curl_exec($curl);

curl_close($curl);

print $result;


?>

https://developer.flowroute.com/api/messages/v2.1/send-an-sms/


https://phppot.com/php/php-curl-post/
curl version


curl https://api.flowroute.com/v2.1/messages \
-H "Content-Type: application/vnd.api+json" -X POST -d \
'{"to": "18412345676", "from": "18452375521", "body": "Hello World !"}' \
-u ambiorixg12:d99a3deadfe43

viernes, 13 de enero de 2023

gogle calendar

 -------------------

require_once __DIR__ . '/vendor/autoload.php';


// Get the API client and construct the service object.

$client = getClient();

$service = new Google_Service_Calendar($client);


// Define the event details.

$event = new Google_Service_Calendar_Event(array(

    'summary' => 'Test Event',

    'location' => 'Test Location',

    'description' => 'Test Description',

    'start' => array(

        'dateTime' => '2022-01-01T09:00:00-07:00',

        'timeZone' => 'America/Los_Angeles',

    ),

    'end' => array(

        'dateTime' => '2022-01-01T17:00:00-07:00',

        'timeZone' => 'America/Los_Angeles',

    ),

));


// Insert the event into the calendar.

$calendarId = 'primary';

$event = $service->events->insert($calendarId, $event);

---------------------------------------

require_once __DIR__ . '/vendor/autoload.php';

$client = new Google_Client();
$client->setApplicationName('My Calendar App');
$client->setScopes(Google_Service_Calendar::CALENDAR);
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');
$calendarService = new Google_Service_Calendar($client);

$event = new Google_Service_Calendar_Event(array(
  'summary' => 'Test Event',
  'location' => 'My House',
  'description' => 'Testing the calendar API',
  'start' => array(
    'dateTime' => '2022-03-28T09:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'end' => array(
    'dateTime' => '2022-03-28T17:00:00-07:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'recurrence' => array(
    'RRULE:FREQ=DAILY;COUNT=2'
  ),
  'attendees' => array(
    array('email' => 'attendee1@example.com'),
    array('email' => 'attendee2@example.com'),
  ),
  'reminders' => array(
    'useDefault' => FALSE,
    'overrides' => array(
      array('method' => 'email', 'minutes' => 24 * 60),
      array('method' => 'popup', 'minutes' => 10),
    ),
  ),
));

$calendarId = 'primary';
$event = $calendarService->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);

------------------



To install the Google Calendar PHP REST API, you will need to use Composer, a package manager for PHP. Here are the general steps to install the API:

  1. Install Composer if you haven't already by following the instructions on their website: https://getcomposer.org/

  2. In your project directory, create a new file called "composer.json"

  3. In the composer.json file, add the following require statement: "require": { "google/apiclient": "^2.0" }

  4. Run the following command in your terminal: composer install

  5. In your PHP script, include the autoloader file by adding the following line at the top of your script: require_once 'vendor/autoload.php';

  6. Use the Google Calendar API by creating an instance of the Google_Client class and using its methods to interact with the Calendar API.

  7. You also need to setup a google project in order to get the credentials(client_id, client_secret, etc) to use it in your php script.

  8. Once you are authenticated and authorized, you can now use the Google Calendar API to manage calendar events, create new calendars, and more.

Please note that this is a high-level overview of the process and you should refer to the official documentation for more detailed instructions and examples: https://developers.google.com/calendar/api/v3/quickstart/php

domingo, 1 de enero de 2023

Mobile Responsive table

 <style>

table {
  border: 1px solid #ccc;
  border-collapse: collapse;
  margin: 0;
  padding: 0;
  width: 100%;
  table-layout: fixed;
}

table caption {
  font-size: 1.5em;
  margin: .5em 0 .75em;
}

table tr {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  padding: .35em;
}

table th,
table td {
  padding: .625em;
  text-align: center;
}

table th {
  font-size: .85em;
  letter-spacing: .1em;
  text-transform: uppercase;
}

@media screen and (max-width: 600px) {
  table {
    border: 0;
  }

  table caption {
    font-size: 1.3em;
  }
  
  table thead {
    border: none;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }
  
  table tr {
    border-bottom: 3px solid #ddd;
    display: block;
    margin-bottom: .625em;
  }
  
  table td {
    border-bottom: 1px solid #ddd;
    display: block;
    font-size: .8em;
    text-align: right;
  }
  
  table td::before {
    /*
    * aria-label has no advantage, it won't be read inside a table
    content: attr(aria-label);
    */
    content: attr(data-label);
    float: left;
    font-weight: bold;
    text-transform: uppercase;
  }
  
  table td:last-child {
    border-bottom: 0;
  }
}














/* general styling */
body {
  font-family: "Open Sans", sans-serif;
  line-height: 1.25;
}
</style>
<table>
  <caption>Statement Summary</caption>
  <thead>
    <tr>
      <th scope="col">Account</th>
      <th scope="col">Due Date</th>
      <th scope="col">Amount</th>
      <th scope="col">Period</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td data-label="Account">Visa - 3412</td>
      <td data-label="Due Date">04/01/2016</td>
      <td data-label="Amount">$1,190</td>
      <td data-label="Period">03/01/2016 - 03/31/2016</td>
    </tr>
    <tr>
      <td scope="row" data-label="Account">Visa - 6076</td>
      <td data-label="Due Date">03/01/2016</td>
      <td data-label="Amount">$2,443</td>
      <td data-label="Period">02/01/2016 - 02/29/2016</td>
    </tr>
    <tr>
      <td scope="row" data-label="Account">Corporate AMEX</td>
      <td data-label="Due Date">03/01/2016</td>
      <td data-label="Amount">$1,181</td>
      <td data-label="Period">02/01/2016 - 02/29/2016</td>
    </tr>
    <tr>
      <td scope="row" data-label="Acount">Visa - 3412</td>
      <td data-label="Due Date">02/01/2016</td>
      <td data-label="Amount">$842</td>
      <td data-label="Period">01/01/2016 - 01/31/2016</td>
    </tr>
  </tbody>
</table>

https://codepen.io/AllThingsSmitty/pen/MyqmdM