Saturday 28 July 2018

Laravel Basics for Beginners

Laravel Basics for Beginners

Question: What is Laravel?
Laravel is a open-source PHP framework used for Developing the websites.


Question: What developed the Laravel?
Taylor Otwell.


Question: When Laravel was launched?
June 2011


Question: What is current stable version of Laravel?
Version 5.2.36 dated June 6, 2016


Question: In which language it was written?
PHP.


Question: What is offical website URL of Laravel?
laravel.com.


Question: Is Laravel an Open Source?
Yes, Download the framework and use as per your requirement


Question: How to install Laravel?
We can install the Laravel in following ways.
  1. Laravel Installer
  2. Composer Create-Project



Question: Explain about Laravel Project?
Laravel is one of the most popular PHP frameworks used for Web Development.
This framework is with expressive, elegant syntax.
It is based on model–view–controller (MVC) architectural pattern.


Question: What are the feature of Laravel5.0?
  1. Method injection
  2. Contracts
  3. Route caching
  4. Events object
  5. Multiple file system
  6. Authentication Scaffolding
  7. dotenv – Environmental Detection
  8. Laravel Scheduler



Question: What is system requirement for installation of Laravel 5.2 (latest version)?
  1. PHP >= 5.5.9
  2. OpenSSL PHP Extension
  3. PDO PHP Extension
  4. Mbstring PHP Extension
  5. Tokenizer PHP Extension



Question: How to install Laravel5.0/Laravel 5.1 with detail steps?
Install Laravel 5.0
Install Laravel 5.1


Friday 27 July 2018

Google speech API with Punctuation and word timestamp in PHP

Google speech api with Punctuation and word timestamp

Question: What is Speech Recognition?
Google Cloud Speech-to-Text enables developers to convert audio to text by applying powerful neural network models in an easy to use API. The API recognizes 120 languages and variants.


Question: Does it provide Speech Recognition for real-time streaming?
Yes, Its provide for both real-time streaming or pre-recorded audio.


Question: What are the different languages for it provides speech to text?
https://cloud.google.com/speech-to-text/docs/languages


Question: Does it return immediately?
Cloud Speech-to-Text can stream text results, immediately returning text as it’s recognized from streaming audio or as the user is speaking.
For short audio (less than a min), It return results.

For Longer audio, Its take time (1min -20) depend on audio file length.


Question: What are different Models for Speech to Text?
  1. command_and_search: Best for short queries such as voice commands or voice search.
  2. phone_call: Best for audio that originated from a phone call .
  3. video: Best for audio that originated from video or includes multiple speakers
  4. default: Best for audio that is not one of the specific audio models.

You can set model in following way
$operation = $speech->beginRecognizeOperation(
   'gs://product_id/file_name.wav',
    array('model'=>'video')
); 



Question: What are the pricing for speech to text?
https://cloud.google.com/speech-to-text/pricing



Question: How to set private key in the environment?
putenv('GOOGLE_APPLICATION_CREDENTIALS=priviate_key_json.json'); 



Question: How to get punctuation in results?
punctuation are the character which we use in written. for example comma(,), perios(.), question mark?.
You can get the punctuation in transcription results by providing enableWordTimeOffsets=true in the config.

for example:
You can set enableWordTimeOffsets in following way
$operation = $speech->beginRecognizeOperation(
   'gs://product_id/file_name.wav',
    array('enableWordTimeOffsets'=>true,'model'=>'video')
); 



Question: What is office link for speech to text?
https://cloud.google.com/speech-to-text/


Question: What is Github link for speech to text?
https://github.com/GoogleCloudPlatform/google-cloud-php-speech


Question: How to install the SDK for speech to text?
php composer.phar require google/cloud-speech



Question: How to get the transcription for small audio file.?
$audioFilePath='gs://ar10w12018/1135-19114_720p.wav';//You can place your path here
$speech = new SpeechClient([
    'languageCode' => 'en-US'
]);

// Recognize the speech in an audio file.
$results = $speech->recognize(
   $audioFilePath,
);

foreach ($results as $result) {
    echo $result->topAlternative()['transcript'] . "\n";
}   



Question: How to get the transcription for heavy audio file.?
for heavy files, make sure you have already uploaded to google cloud and you have path.

$audioFilePath='gs://ar10w12018/1135-19114_720p.wav';//You can place your path here
                $speech = new V1p1beta1\SpeechClient([
                    'languageCode' => 'en-US',
                ]);
                $config = new V1p1beta1\RecognitionConfig();
                $config->setLanguageCode('en-US');
                $config->setEnableWordTimeOffsets(true);
                $config->setEnableAutomaticPunctuation(true);
                $config->setModel('video');
                
                $audio = new V1p1beta1\RecognitionAudio();
                $audio->setUri($audioFilePath);
                $operation = $speech->longRunningRecognize($config, $audio);
                
              $result['operation']=$operation->getName();//operation name
 

You can get the results by using Operation Name.
$operationName='194790781308823479';
$speech = new SpeechClient([
    'languageCode' => 'en-US'
]);
$operation = $speech->operation($operationName);

$isComplete = $operation->isComplete();
if($isComplete){
$results=$operation->results();
}