GeezerVison is showing github.com — [cloud speech] the right way to get a transcript from operation? base64 decode!? · Issue #2312 · googleapis/google-cloud-node
[cloud speech] the right way to get a transcript from operation? base64 decode!? #2312Labels api: speechIssues related to the Speech-to-Text API.priority: p2Moderately-important priority. Fix may not be included in next release. Description
Though I couldn't find the usage of operation reference to get a transcript result.
I found something similar by base64-decoding operation.metadata.response.value..
The strange thing is I got some special characters after decoding the value.
Could you share the the right way to get a transcript from operation?
var operation = speechClient.operation('68850831366825');
operation.get({},function(err,res){
if (err){
console.log(err);
return;
}
var metadata = res.metadata;
var isDone = metadata.done;
if (isDone && metadata.response) {
var b64string = metadata.response.value;
var buf = new Buffer(b64string, 'base64');
var transcript = buf.toString('utf8');
.....
}Activitystephenplusplus commented on May 17, 2017 Just confirming the use case-- you are trying to get the transcript from a recognition request that was run in another process at another time? Reacted by Kenson Leung W.K and Maxime Liron mfkenson commented on May 18, 2017 stephenplusplus commented on May 18, 2017 Thanks. We haven't designed an ideal solution for this, so the way you've been doing it would be the most correct. Off hand, I'm not sure what a good API would look like for this, so feel free to make suggestions / send a PR! stephenplusplus commented on Jun 12, 2017 ximus commented on Jun 25, 2017 as a followup to to @mfkenson's snippet in the issue summary:
the base64 string found at metadata.response.value isn't usable data. It is the protocol buffers representation of the results. To get the result data, I am doing the following contortion to get useful data:
...
const results = speechClient.api.Speech.longrunningDescriptors.longRunningRecognize.responseDecoder(metadata.response.value).results
const result = map(results, r => r.alternatives[0].transcript).join('')
there may be a pretty way of doing this, but i've invested enough time in this for now.
This remains brittle solution as it relies on a deeply nested private API.
I find this public speechClient.operation rather useless in its current form and its presence on the public API more misleading than helpful as I couldn't find a public way of doing anything useful with the result set. Did I miss something? I certainly couldn't find any doc or examples showing me better.
I recommend you consider either deprecating it, augmenting it or putting a prominent warning about its limited use in the doc Reacted by Tema Smirnov Reacted by Tema Smirnov ximus commented on Jun 25, 2017 I'd like to note that the use case it caters to (startRecognition in one process, poll for results in another) is an important use-case in my opinion.
Longer audio files can take real long to process by the speech API. I'm using Cloud Functions to startRecognition and I can't afford to have a function sit around waiting for the promise to resolve. Also, I just run into the max runtime quota for those and the function instance is forcibly terminated. Reacted by Kenson Leung W.K, Tema Smirnov and Mirek Krymski mfkenson commented on Jun 30, 2017 @ximus Even I could afford to sit and wait, there will be timeout exception (grpc) evaogbe commented on Aug 8, 2017 Hi @mfkenson,
Thank you for reporting this.
Since the time that you reported this issue, we released an entirely new version of google-cloud-speech with significant alterations. Could you upgrade to the newest version (note that code changes will be necessary to use the new thing; your existing code will use the former, now deprecated code path), and it should fix this problem for you.
I am going to close this, but feel free to re-open if the issue persists. evaogbe commented on Feb 2, 2021 I am no longer on the team
MetadataMetadataapi: speechIssues related to the Speech-to-Text API.priority: p2Moderately-important priority. Fix may not be included in next release. DevelopmentNo branches or pull requestsIssue actions
|