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',
	api_key => 'xxxxx'
);

# 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

api_key

my $key = $speech->api_key;
my $key = $speech->api_key('xxxxNEWKEYxxxx');
Cloud Speech API key, used for authanitication.  Usually set using L</new>.

See https://cloud.google.com/docs/authentication 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');

lang

my $lang = $speech->lang('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. 
L<https://cloud.google.com/speech/docs/languages>

rate

my $sample_rate = $speech->rate('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;
	}
}

is_done

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

results

print Dumper $speech->syncrecognize->results;

returns the converted data as Arrayref.

syncrecognize

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

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

AUTHOR

Prajith NDZ prajith@ndimensionz.com

COPYRIGHT AND LICENSE

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

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