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();
}



Wednesday, 25 July 2018

AWS interview questions and answers for 1 year experienced

AWS interview questions and answers for 1 year experienced

Question: What is the difference between Amazon S3 and Amazon EC2 instance?
Amazon S3: It is just storage service where you can upload photo, video, audio, pdf etc any type of files upto 5 terabytes (5Tb).
It store data as a object, you can't install any software like MS office, VLC player, Adobe etc.

You can import/export data from/to S3 and also can access via cloudfront.

EC2 instance: Launching a EC2 instance is similar a create virtual computer (windows, linux) where you can install software unlike S3. You can customize the configuration like volume(storage), RAM, CPU etc.


Question: How to copy files from one bucket to another?
  1. Login to SSH using ip address and ppk file.
  2. Make sure, it have AWS S3 access privilege
  3. Now just execute following command
    aws s3 sync s3://source-bucket s3://destination-bucket --exclude *.tmp
    



Question: Can we change the availability zone of an existing EC2 t1.micro instance?
No, you can not do.
for this, you need to launch new instance from existing instance.



Question: What is Availability Zones?
Amazon EC2 is hosted in world-wide.
These locations are composed of regions and Availability Zones.
Each region has multiple, isolated locations known as Availability Zones.


Question: How to move files directly from one S3 account to another?
Bucket Explorer works on Mac
S3 Browser works on windows.



Question: AWS Difference between a snapshot and AMI?
A snapshot is of an EBS volume where you save at a certain point of time.
An AMI is similar, but its for the EC2 instances themselves. you can create a AMI but can't do snapshot.


Question: What is the maximum length of a filename in S3?
1024 characters.



Question: How to move a domain from Godaddy to AWS Route 53? =>Login on your aws console
=>Click on Route 53
=>Create Hosted Zone
=>Select your new created host title
=>click "Go to Record Sets", take note of the nameservers;

=>Login on your Godaddy account
=>Select your domain
=>Go to Nameservers and click SetNameservers;
=>paste all the four you took from Go to Record Sets;


Question: How to transfer files between from AWS ec2 to S3
aws s3 cp myfolder s3://mybucket/myfolder --recursive



Question: How to transfer files between from S3 to EC2
aws s3 cp s3://mybucket/myfolder myfolder  --recursive



Question: Question: What is private hosted zone?
A private hosted zone is a container that holds information about how you want Amazon Route 53 to respond to DNS queries for a domain



Question: What is the AWS Storage Gateway service?
The AWS Storage Gateway service enables hybrid storage between on-premises environments and the AWS Cloud.