sábado, 14 de julio de 2018

google speech api

C#

GO

JAVA

NODE.JS

PHP

PYTHON

RUBY

composer require google/cloud-speech

Make an audio transcription request

Now you can use Speech-to-Text to transcribe an audio file to text. Use the following code to send a recognizerequest to the Speech-to-Text API.

C#

GO

JAVA

NODE.JS

PHP

PYTHON

RUBY

# Includes the autoloader for libraries installed with composer require __DIR__ . '/vendor/autoload.php'; # Imports the Google Cloud client library use Google\Cloud\Speech\SpeechClient; # Your Google Cloud Platform project ID $projectId = 'YOUR_PROJECT_ID'; # Instantiates a client $speech = new SpeechClient([     'projectId' => $projectId,     'languageCode' => 'en-US', ]); # The name of the audio file to transcribe $fileName = __DIR__ . '/resources/audio.raw'; # The audio file's encoding and sample rate $options = [     'encoding' => 'LINEAR16',     'sampleRateHertz' => 16000, ]; # Detects speech in the audio file $results = $speech->recognize(fopen($fileName, 'r'), $options); foreach ($results as $result) {     echo 'Transcription: ' . $result->alternatives()[0]['transcript'] . PHP_EOL; }
https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries#client-libraries-install-php

No hay comentarios:

Publicar un comentario