11

I have an unused key on my computer keyboard, and would like to turn it into a "Google interphone".
How it would work:

  • Press the key (and keep it pressed)
  • Say "Nairobi weather"
  • Release the key
  • Immediately the software would open a web browser tab on Google Voice Search searching for what I said.

Requirements:

  • Linux
  • Start listening fast. I should be able to press the key and start speaking immediately, without having to wait for anything to load.
  • No user interface (except maybe for settings)
  • Do not try to do speech recognition, just send the audio to Google, like on mobile.

enter image description here

  • I know how to launch a Google search by voice only in Windows if interested. Linux generally sucks for voice recognition (the best you can find it usually some program using Google API for voice recognition, not sure if they have been banned yet). – Franck Dernoncourt Apr 3 '14 at 13:57
  • 1
    The program would not try to do any recognition, it would just send the audio to Google, just like on mobile. – Nicolas Raoul Apr 4 '14 at 0:47
  • lemme guess... CAPSLOCK is the unused key? – NH. Jan 4 at 16:16
2

Ok this isn't a complete answer, but your reference to Google's API got me interested (hadn't heard of it before - and as you said, Linux is not great at voice recognition, so I've never bothered) and it looks like something that could be cool.

The following script should (I say 'should', my computer here doesn't have a mic!) record a snippet, convert it, send it to Google, return it as text, strip the spaces from the text to format it as a URL (needs work no doubt, I've only escaped the spaces), and search Google for it via Firefox. I've not looked at a shortcut key yet, or a better means of stopping the record.

#!/bin/bash

echo "Recording. Use Ctrl+C when finished your query."
arecord -q -f cd -t wav | ffmpeg -loglevel panic -y -i - -ar 16000 -acodec flac file.flac > /dev/null 2>&1

echo "Sending to Google"
wget -q -U "Mozilla/5.0" --post-file file.flac --header "Content-Type: audio/x-flac; rate=16000" -O - "http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium" | cut -d\" -f12  >search_query.txt

sed -i "s# #+#g" search_query.txt
SEARCH=$(cat "search_query.txt")

firefox -new-tab https://www.google.co.uk/search?q=$SEARCH

rm -f file.flac

Any suggestions on where to go next would be appreciated no doubt! I'll keep tinkering though..

2

EasyVoiceSearch, an extension for Chromium/Chrome

Pros:

  • Almost immediate. You have to wait 1–2 seconds to start talking.
  • No user interface. Settings are in chrome://extensions. Sometimes, there's a red circular microphone icon on the right side of Chromium's omnibar though.
  • Probably uses Google voice recognition. The description doesn't say whether it does.

Cons:

  • You have to keep Chromium open.
  • It's a keyboard combo, not a key press. You can't bind it to special keys like "menu" or "super", or to "control" without something like "ctrl+A".
  • The keyboard combo is pressed once, not held down. Like in the mobile apps, Google stops listening when you stop talking.
  • Search results are in the background. After you finish talking, Chromium is still in the background, so you'll have to switch to it manually.
  • Search results are in Chromium. The search results won't appear in Firefox, for example.
  • Answers aren't spoken aloud. If you say "Nairobi weather", you won't get an auditory response.

Setup:

Install it from the Chrome Web Store.

To get a key binding for it (after you add it to Chromium):

  • Go to chrome://extensions (in Chromium)
  • Scroll down and select Keyboard shortcuts
  • Under EasyVoiceSearch, set a keyboard shortcut
  • Change "In Chrome" to "Global"

The first time you use it, you'll have to accept letting the page use your microphone.

  • Answers aren't spoken aloud <- No problem, this was not a requirement anyway :-) – Nicolas Raoul Sep 29 '14 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.