Mixing Annyang with Wolfram Alpha, that is, giving intelligence to Antonia

Well, What's this about? You may know that I'm not a friend of Google Home or Alexa devices, for the mere fact that you can't change their name (For now), so in my case I use Annyang to call her Antonia and customize the orders. But why put Wolfram Alpha in it?

GOOD, Wolfram Alpha as many of you know, It's like a tool with a large database of information, by means of a website We can ask you any question you will almost certainly know the answer. From historical themes, to sports results, and of course complex mathematical calculations. As I was saying, The usual use is to make inquiries via the web and in English; it can be used through API but it is paid if we do more than 2000 Monthly consultations (or we use it for commercial purposes).

So, the idea is to ask our Antonia questions, review This old post if you don't have your own virtual assistant in place. Total that, we will say something like Antonia: “Antonia, question, Who is Julio Iglesias?”, and by means of a script, Let's go a (i) Pick up everything that comes after the word 'ask', (Ii) Let's translate it into English, (Iii) let's ask Wolfram Apha, (Iv) Let's collect the answer he gives us, (v) we are going to translate it from English to Spanish and (Saw) He will say it over the loudspeakers (in my case he will send it to Home Assistant, and it will play it on your home speakers thanks to Snapcast). And all this with a lightning-fast response, that works great!

GOOD, on the machine where our Apache runs with Annyang we will create the script that will be called to make the query. In my case it's called antonia_pregunta.sh

#!/Bin/sh echo "$1" | Cut -D " " -F2- > /Home/Hector/Wolfram-Antonia/1peticion_sin_pregunta.txt Peticion_Sin_Pregunta='CAT /Home/Hector/Wolfram-Antonia/1peticion_sin_pregunta.txt' /Home/Hector/Wolfram-Antonia/Trans :In -Brief "$Peticion_Sin_Pregunta" > /home/hector/wolfram-antonia/1peticion_en.txt TranslatePetition='cat /home/hector/wolfram-antonia/1peticion_en.txt' curl -s "https://api.wolframalpha.com/v1/result?appid=XXXXXX-XXXXXXXXXX&units=metric&" --data-urlencode "i=$TraducePeticion" > /home/hector/wolfram-antonia/2respuesta.txt TranslateAnswer='cat /home/hector/wolfram-antonia/2respuesta.txt' /home/hector/wolfram-antonia/trans :en -brief "$TranslateAnswer" > /home/hector/wolfram-antonia/2respuesta_es.txt AnswerES='cat /home/hector/wolfram-antonia/2respuesta_es.txt' curl -X POST -H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXX" -H "Content-Type: application/json" -d '{"entity_id": "media_player.volumio_mpd", "Message": "'"$AnswerEN"'"}' http://192.168.1.116:8123/api/services/tts/google_say

This script is kind of crappy, but totally valid for a dinosaur like me. Need Register our app to use the Wolfram Apha APIs (and enter your ID in the script), and in my case also when sending it to the Home Assistant speakers, by curling an API call to make it Google_Say; But, well, Everyone can do as they want, The script works that easy: “./antonia_pregunta.sh “question: Who is Julio Iglesias?”. What I said, He takes away the first word, he translates it and will give us the answer, Then as you want you send it to your speakers 🙂

But before we can run the script we will need to meet one more requirement, We need a translator! And what better than this wonder, Through this simple script we will be able to quickly translate between any language (As an argument we could use the target language, among other options).

wget git.io/trans chmod +x ./trans ./trans :en -brief "Hi there, How are you?"

And it's ready, in Antonia's php file we will not forget to add that when you hear her name followed by the word 'question', Run this script, Staying:

...
elseif (strpos($value, 'pregunta') === 0)
{
    Exec('/home/hector/bong.sh');
    Exec('/home/hector/wolfram-antonia/antonia_atenta.sh "'.$valor.'" ');
}
...

Maybe it's a mess, But it's not at all complicated to really set it up, This way we will give our own virtual assistant more intelligence, or that, or you use a commercial one. That insurance is less flexible and just as insecure 😉

I hope it has been of interest to you, thanks for sharing on social media.

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!