Google Speech Api Credential Error with Raspbian (Raspberry pi) - python

i want to make a speech to text program so i used Google Speech Api.
When i launched the code on my pc it works, but on raspberry pi it doesnt. Probably it is about Credential, but i tried so many things. For example:
i add GOOGLE_APPLICATION_CREDENTIALS with this command:
sudo nano ~/.bashrc
but it still creates error
i dont know what should i do.

You would need to restart your terminal for the commands in .bashrc to take effect. If you don't want to restart the terminal, type
export GOOGLE_APPLICATION_CREDENTIALS="<creds>"

Related

What is the terminal script to run CoAP server

Im trying to run this CoAP server from https://github.com/Tanganelli/CoAPthon on a raspberry pi. i cant seem to find much instructions. This was one of the CoAP that my instructor wanted us to use, my instructor pretty much left us hanging with no help at all but this link.
i followed the install instructions on the github page, the only thing that wouldnt install is the section
Install instructions for CoRE Resource Directory. Mongod wouldnt install for this section so i gave up. so i dont know if this section is important or not
What are the commands for the terminal to get it running and doing something.
it says to type in to run the server coapserver.py.
cd CoAPthon
python coapserver.py
and from what it looks like its running
but nothing happens, so im not sure if its just not working or if theres just nothing there for it to do, or if there is another file i need to run with the coapserver.py.
Im very new to using CoAP and will eventually need to add a sensor to it do record temp but i want to make sure i know the server is running properly before i add that part in
any input would be great
For future individuals that might need help with this, use aioCoAP, its much easier then CoAPthon
get it from here https://aiocoap.readthedocs.io/en/latest/installation.htmlg
all you need to do is mess with three files labeled server.py, clientPUT.py and clientGET.py
Add resources and classes for sensors and what not to server.py
ClientPUT.py is where you would add your code for the sensors or whatever you need.
ClinetGET.py you alter the uri
run it by type in the command in the terminal (go to directory first that has the server) type in python server.py
in another terminal do the same thing but instead run python clientPUT.py
and the server should be running
then all you need is a client for the get request. If you were like me and needed to use Copper go here to install it for chrome https://github.com/mkovatsc/Copper4Cr

How do i go to a folder in python to execute a python script there?

I'm using the pi_video_looper to loop videos on raspberry pi start. Because I want to use more raspberry pis, and change the videos some times, i changed the program so it would get the videos from a NAS server.
The problem is, that it woun't mount properly. So every time I restart the pi i have to stop the video looper from another computer (sudo supervisorctl stop video_looper), mount the pi again (sudo mount -a) and restart the video looper (cd /home/pi/pi_video_looper; sudo ./install.sh).
I tried to write a python script that would simply write the commands into terminal (with os.system). This almost works. The only thing is, that the install.sh doesn't work properly when I start it from "home". So I need a command that would do the same as cd /home/pi/pi_video_looper so I can execute install.sh directly.
Does anyone have any ideas?

How do I make my discord bot stay online

I recently made a music bot in my discord server but the problem I have is that I have to turn on the bot manually etc. and it goes offline when I turn off my computer. How can I make the bot stay online at all times, even when I'm offline?
You need to run the python script on a server, e.g. an EWS linux instance.
To do that you would need to install python on the server and place the script in the home directory and just run it via a screen.
Use a Raspberry Pi with an internet connection. Install all necessary components and then run the script in its terminal. Then, you can switch off the monitor and the bot will continue running. I recommend that solution to run the bot 24/7. If you don't have a Raspberry Pi, buy one (they're quite cheap), or buy a server to run the code on.

Run python script right after RPi boot

I'm relatively new to raspberry pi (5 days using it) and I've just finished to run my python script succesfully (called dogcare.py). Now I'm trying to execute this script right after my raspberry is turned on. I've been doing some research and I find different ways to do it:
using /etc/profile
using /etc/rc.local
using crontab
using /etc/init.d
using systemd
But none of these ways are working for me.
Setup enviroment:
Hardware: RaspberryPi 2 Model B
Software: Raspbian or NOOBs (not sure)
Context:
Since for my project I need to run meet.jit.si, I followed this guide http://www.instructables.com/id/Video-Calling-on-Raspberry-Pi-3/?ALLSTEPS and It has a step where sets chromium website to start right after RPi is turned on. (Currently this is working fine)
My python script is using request library in order to use HTTP GET with an external website application I've been working on.
Main problem:
I need to run both events: chromium website with meet.jit.si and my python script when my raspberry is turned on.
Current situation: chromium website is running after my RPi is turned on but my script doesn't.
I'd appreciate any help !
I have done a similar thing with my Raspi 2 as well which involved sending myself an email with the ip address of the pi so I could easily ssh/vnc to it.
My steps involved making a shell script which ran the python program.
#!/bin/sh
cd pythonfiledirectory
sudo python pythonfile.py
cd /
Then I made it executable with the following command:
chmod 777 file.sh
Now edit your crontab to run the file on startup.
In your terminal, type:
sudo crontab -e
Inside of the crontab write:
#reboot sh file.sh
You could add a log file if you wanted to debug and see why it's not working by making a log directory and changing the text you wrote in the crontab to:
#reboot sh file.sh >/logdirectoy/ 2>&1
This is what made it work for me and if it doesn't work try and make sure you can run your .sh file and try the crontab with some other files to debug the problem.

Raspberry Pi - Run Python script at Startup using "screen" session

I have really tried looking around but all the examples I find do not work for me.
I have a python script in a Raspberry Pi that starts using CRON....all good!
I would like to be able to debug the ouput that the script prints in screen from time to time so the "screen" command needs to be used to create a session and ensure that I can login and logoff using putty as needed.
I also add the "&" so it will run in background.
So currently I did:
1) Open cron
sudo crontab -e
2) Add the following line
#reboot python /home/pi/python/monitor.py &
This works correctly, I just need to know how to make a "screen" session open before launching the python script.
Thank you very much for your help!

Categories

Resources