i am using google speech to text in php codeigniter here my controller:
<?php
defined('BASEPATH') or exit('No direct script access allowed');
use GoogleCloudSpeechV1RecognitionAudio;
use GoogleCloudSpeechV1RecognitionConfig;
use GoogleCloudSpeechV1SpeechClient;
use GoogleCloudSpeechV1RecognitionConfigAudioEncoding;
use GoogleCloudSpeechV1StreamingRecognitionConfig;
class SpeechToText extends CI_Controller
{
public function index()
{
$this->config->load('google_speech', TRUE);
$credentialsPath = $this->config->item('google_speech_credentials_path', 'google_speech');
// Create Speech Client
$speech = new SpeechClient([
'credentials' => $credentialsPath
]);
$recognitionConfig = new RecognitionConfig();
$recognitionConfig->setEncoding(AudioEncoding::FLAC);
$recognitionConfig->setSampleRateHertz(44100);
$recognitionConfig->setLanguageCode('en-US');
$config = new StreamingRecognitionConfig();
$config->setConfig($recognitionConfig);
$url = base_url('uploads/file_example_WAV_1MG.wav');
$audioResource = fopen($url, 'r');
$responses = $speech->recognizeAudioStream($config, $audioResource);
foreach ($responses as $element) {
// doSomethingWith($element);
}
}
}
And this is the error i am facing:
Type: GoogleProtobufInternalGPBDecodeException
Message: Error occurred during parsing: Fail to push limit.
i tried many solution but nothing work i work on local serve. i installed package google/cloud-speech
.
pls give solution for this
New contributor
user24973246 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.