Exemple #1
0
 
}
*/
//  if($e==null){
echo "</br>File is ready for the convertion in Flac </br>";
//"/flac2mp3/./mp32flac.sh ";
$output = system("ffmpeg -i " . $real . "ciao.mp3 " . $real . "ciao.flac");
// echo "</br> E".$output;
echo "Convertion is finish </br>";
echo $real . "ciao.flac";
echo "</br>";
print_r(error_get_last());
include 'GoogleSpeechToText.php';
// Your API Key goes here.
echo " include work";
$speech = new GoogleSpeechToText("AIzaSyDNsTkS0Jm6NQRFbaHKBHsaRO6BXNcjOtw");
echo "File flac is ready for to be converted in text </br>";
//CAMBIARE QUANDO STA SUL SERVER
//$file = realpath( '/home/a2124875/public_html/quick.flac');
$file = $real . "ciao.flac";
echo $file;
$bitRate = 44100;
// The bit rate of the file
$result = $speech->process($file, $bitRate, 'it-IT');
print_r(error_get_last());
/*

$result = $speech->process($file, $bitRate, 'it-IT');


<?php

include 'GoogleSpeechToText.php';
// Your API Key goes here.
$apiKey = 'AIzaSyCbBqke_xLXiUFZd8rPuJiGJA5mnhqPeSM';
$speech = new GoogleSpeechToText($apiKey);
$file = realpath('./uploads/output.flac');
// Full path to the file.
$bitRate = 44100;
// The bit rate of the file.
$result = $speech->process($file, $bitRate, 'en-US');
var_dump($result);
Exemple #3
0
include 'GoogleSpeechToText.php';
$data = array();
if (isset($_GET['files'])) {
    $error = false;
    $files = array();
    $uploaddir = './uploads/';
    foreach ($_FILES as $file) {
        $newFile = $uploaddir . basename($file['name']);
        if (move_uploaded_file($file['tmp_name'], $newFile)) {
            $files[] = $uploaddir . $file['name'];
            $path_parts = pathinfo($newFile);
            $newFileName = $path_parts['filename'];
            $newFileName = $newFileName . '.flac';
            $command = "~/bin/ffmpeg -i " . $newFile . " ./uploads/" . $newFileName;
            shell_exec($command);
            $apiKey = 'AIzaSyCbBqke_xLXiUFZd8rPuJiGJA5mnhqPeSM';
            $speech = new GoogleSpeechToText($apiKey);
            $file = realpath('./uploads/' . $newFileName);
            // Full path to the file.
            $bitRate = 44100;
            // The bit rate of the file.
            $output = $speech->process($file, $bitRate, 'en-US');
        } else {
            $error = true;
        }
    }
    $data = $error ? array('error' => 'There was an error uploading your files') : array('command' => $output);
} else {
    $data = array('success' => 'Form was submitted', 'formData' => $_POST);
}
echo json_encode($data);