Sending asynchronous speech recognition request through gcloud, getting no response - google-cloud-speech

So, to confirm: I believe I have set everything up correctly as I was able to run the sample code for the recognize-long-running method. It quickly returned a name and a json file with the transcription.
However, when I try to run the same code for my own audio sample, nothing happens. The API dashboard shows that a request came through, but my Terminal hangs with no response. I am using a Mac, High Sierra 10.13.6, and running the code from the command line. I also have a project set up in Google Cloud Platform and have the file in question uploaded in flac format. Noteworthy, perhaps: my sample has a bitrate of 48000, which is higher than their recommended one, so perhaps this is messing things up?
I will paste the sample code that works below, in addition to my code.
Working sample code from Google:
gcloud ml speech recognize-long-running \
'gs://cloud-samples-tests/speech/brooklyn.flac' \
--language-code='en-US' --async
My code:
gcloud ml speech recognize-long-running \ 'gs://interviewtexttospeechconversions/MelvinWeek4.flac’ \
     --language-code='en-US' --async --

I think that your terminal is getting hang with no response since you are using a (`) character to close the file name quote instead of the (') character. Additionally, I think is required to remove the -- symbol, located at the end of the gcloud command, in case you are not planning to add another parameter.
gcloud ml speech recognize-long-running 'gs://interviewtexttospeechconversions/MelvinWeek4.flac' --language-code='en-US' --async
Finally, I recommend you to include the sample-rate and encoding parameters that can help you to avoid invalid configuration issues.

Related

ROS: How to use sound_play to speak messages published to a topic?

I am a beginner with ROS and am trying to use ROS sound_play package to speak out loud my messages (which is in string format) that I have published to a particular topic.
So far, I am able to print out the messages onto my ROS terminal using the command $rostopic echo / , but I want my machine to concurrently SPEAK these exact messages that are printed out on my terminal.
I have also tried the command $rosrun sound_play say.py "" for my machine to speak the specific string text I input. My question is, how can I integrate sound_play to actually speak out the messages published to my topic that I have printed onto my terminal using the echo command?
Any help would be appreciated, thanks!
I think instead of using this package, I would recommend using a Python text to speech library like https://pypi.org/project/pyttsx3/
Instead of publishing the string, you can simply pass the string to the API of this library to play the sound.
Hope this helps.

How do i hit URL using Tcl script?

I am working in Tcl 8.1 and now I am trying to hit an URL using the following command from Tcl Script (which will be called from my application)
eval exec [auto_execok start] [list "" $url]
But the problem is, it is opening the URL in a web browser. But I don't want the web browser to open as per my requirement. I just want to hit the URL in background.
Is there any solution available to this problem?
Any help would be greatly appreciated.
It isn't exactly obvious what "hit[ting an] URL in background" means, but I'm guessing that you want to retrieve the contents at an URL and make them available as data in your program.
The http module contains the commands you need for this. Basic use:
package require http
set token [::http::geturl $url]
puts [::http::data $token]
::http::cleanup $token
Documentation: http
P.S. you really need to upgrade, if possible. Even Tcl 8.4 is obsolete nowadays. You will risk having subtle, hard-to-diagnose problems with your programs unless you use a recent version, and a lot of the suggested code for instance here or on the wiki will be unusable to you with a version that old. And Tcl just keeps getting better.
You want to send literal quotes as the first argument for start, not an empty string.
eval exec [auto_execok start] {""} [list $url]
ref: http://wiki.tcl.tk/auto_execok

Running graphgists locally fails

I'm interested in running a graphgist locally, for which there is a script here:
https://gist.github.com/jexp/70296ce410ff431ddbef
I was able to install the modules and run the two tasks but the last line of the script:
open http://localhost:8000/?http%3A%2F%2Flocalhost%3A8000%2Fgists%2Fmy-graph-use-case.adoc
produces an error: Not Found and trying to open the link in the comments:
http://localhost:8000/gists/my-graph-use-case.adoc
causes my browser to download a file for which I have no associated application. has anyone made this work and if so, how?
according to #MichaelHunger the issue is that the default behaviour in Python's SimpleHTTPServer is such that a trailing slash (/) gets added to the end of the url, messing up the request.
according to #PratikMandrekar, in the following article, the problem is that the url as it is in the script does not explicitly specify the file name, forcing the server to redirect to the default. see:
Why does SimpleHTTPServer redirect to ?querystring/ when I request ?querystring?
so after a little experimentation I found this to work:
http://localhost:8000/index.html?http%3A%2F%2Flocalhost%3A8000%2Fgists%2Fmy-graph-use-case.adoc
notice that the colons, slashes, etc. in the inner url must be encoded for this to work
There is a bug/default behavior in simple-http-client that makes it add slashes after query parameters which breaks our app in this case, I have to find a better replacement or fix it.
Perhaps I can also change the rabbithole project to server the graphgist files itself, so that it would be self-contained.

Applescript: print first or other specific pages

How can you instruct an application or the printer to only print the first page, a page range or just odd or even pages of a file? I attempt this with the help of the Preview app, which looks promising:
set theFile to "[file-path/file]""
tell application "Preview"
activate
print theFile with properties {target printer:"Printer", ending page:1} without «class pdlg»
--these properties isn't available for the printer app, here just limiting amount of printed pages
quit
end tell
But with this I'm bitten by the sandboxd process that tells me the file can't be opened for printing and I get a deny file-read-data result in the log.
In the CUPS suggestion by adamh I encounter issues with umlauts and have other execution issues as well, possibly also because of sandbox rules. The code works from the command line, but not when called in automated fashion.
I tried to look up useful examples of the print command in a reference, in my books and tried searching the online Apple references, but I can't seem to find many examples fitting to the present day situation with sandbox, if any.
You could script printing by command line tool lp & lpr.
These talk to CUPS, Common Unix Printing System
To target pages / ranges:
lp -o page-ranges=2-4 "my_great_document.pdf"
To call it from applescript use do shell script
e.g,
do shell script "lp -o page-ranges=2-4 'my_great_document.pdf'"
For more ideas see: http://www.cups.org/documentation.php/options.html

Encode & Post Image via Command Line?

I have a Rails app that has a Picture model using the carrier-wave gem to handle image upload/saving.
Eventually, I plan to have an iOS app POST an image to the Picture model's controller / create action.
Before that, I'd like to test some things locally and simulate the POST event.
Can I do this by encoding/posting via OSX Terminal? I imagine I need to encode the image file into (binary?) and POST it to the controller/action.
The easiest way to simulate this is using the command line utility curl. You can do something like:
curl -X POST -F field1=value1 -F file=#path/to/file.jpg http://example.org/pictures
The -F options allow you to set form field values. For example, your controller might be expecting that a couple form fields will be submitted with the file upload. You can pass in multiple -F name=value options. If the value starts with a #, then curl will read from a file (such as the image you want to upload).
The -X POST makes curl run a POST request to the server. I'm not 100% sure it is necessary, because I think curl will automatically switch to POST since you've included a file with the upload... but it won't hurt anything either.
curl is a very powerful tool. You can get additional information by typing man curl in your OSX Terminal window. It has a lot of options and can handle just about any situation you throw at it.

Resources