NAME

Google::Cloud::Speech - An interface to Google cloud speech service

SYNOPSIS

use Data::Dumper;
use Google::Cloud::Speech;

my $speech = Google::Cloud::Speech->new(
	file        => 'test.wav',
	secret_file => 'my/google/app/project/sa/json/file'
);

# long running process
my $operation = $speech->asyncrecognize();
my $is_done = $operation->is_done;
until($is_done) {
	if ($is_done = $operation->is_done) {
		print Dumper $operation->results;
	}
}

DESCRIPTION

This module lets you access Google cloud speech service.

ATTRIBUTES

secret_file

Loads the JSON file from Google with the client ID informations.

$speech->secret_file('/my/google/app/project/sp/json/file');

To create, Google Service Account Key:

1) Login to Google Apps Console and select your project
2) Click on create credentials-> service account key. 
4) Select a service account and key type as JSON and click on create and downlaoded the JSON file.

See L<Google API Doc|https://developers.google.com/identity/protocols/application-default-credentials> for more details about API authentication.

encoding

my $encoding = $speech->encoding('linear16');

Encoding of audio data to be recognized. Acceptable values are:

		* linear16 - Uncompressed 16-bit signed little-endian samples.
			(LINEAR16)
		* flac - The [Free Lossless Audio
			Codec](http://flac.sourceforge.net/documentation.html) encoding.
			Only 16-bit samples are supported. Not all fields in STREAMINFO
			are supported. (FLAC)
		* mulaw - 8-bit samples that compand 14-bit audio samples using
			G.711 PCMU/mu-law. (MULAW)
		* amr - Adaptive Multi-Rate Narrowband codec. (`sample_rate` must
			be 8000 Hz.) (AMR)
		* amr_wb - Adaptive Multi-Rate Wideband codec. (`sample_rate` must
			be 16000 Hz.) (AMR_WB)
		* ogg_opus - Ogg Mapping for Opus. (OGG_OPUS)
			Lossy codecs do not recommend, as they result in a lower-quality
			speech transcription.
		* speex - Speex with header byte. (SPEEX_WITH_HEADER_BYTE)
        
        

file

my $file = $speech->file;
my $file = $speech->('path/to/audio/file.wav');

language

my $lang = $speech->language('en-IN');

The language of the supplied audio as a BCP-47 language tag. Example: "en-IN" for English (United States), "en-GB" for English (United Kingdom), "fr-FR" for French (France). See Language Support for a list of the currently supported language codes. Language codes

samplrate

my $sample_rate = $speech->samplerate('16000');

Sample rate in Hertz of the audio data to be recognized. Valid values are: 8000-48000. 16000 is optimal. For best results, set the sampling rate of the audio source to 16000 Hz. If that's not possible, use the native sample rate of the audio source (instead of re-sampling).

METHODS

asyncrecognize

Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface.

my $operation = $speech->asyncrecognize();
my $is_done = $operation->is_done;
until($is_done) {
	if ($is_done = $operation->is_done) {
		print Dumper $operation->results;
	}
}

syncrecognize

Performs synchronous speech recognition: receive results after all audio has been sent and processed.

my $operation = $speech->syncrecognize;
print $operation->results;

is_done

Checks if the speech-recognition processing of the audio data is complete. return 1 when complete, 0 otherwise.

results

returns the transcribed data as Arrayref.

print Dumper $speech->syncrecognize->results;

AUTHOR

Prajith P me@prajith.in

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017, Prajith P.

This is free software, you can redistribute it and/or modify it under the same terms as Perl language system itself.

SEE ALSO

DEVELOPMENT

This project is hosted on Github, at https://github.com/Prajithp/p5-google-cloud-speech