dray-cyber / googlecontroller

Google Controller
MIT License
17 stars 1 forks source link

say and mp3 now not working #4

Closed peterd550 closed 3 years ago

peterd550 commented 3 years ago

I used your example - please note I am using Python3

!/usr/bin/env python3

from googlecontroller import GoogleAssistant

host = "10.0.0.1" #again your google homes ip home = GoogleAssistant(host=host) home.serve_media("HappyBirthdaySong.mp3", "/home/scripts") with this version i got

googlecontroller==5 Traceback (most recent call last): File "./test.py", line 2, in from googlecontroller import GoogleAssistant File "/home/busybox/.local/lib/python3.7/site-packages/googlecontroller/init.py", line 1, in from pyngrok import ngrok ModuleNotFoundError: No module named 'pyngrok' i pip installed pyngrok 172.24.0.2 Traceback (most recent call last): File "./test.py", line 7, in home.serve_media("HappyBirthdaySong.mp3", "/home/scripts") File "/home/busybox/.local/lib/python3.7/site-packages/googlecontroller/init.py", line 38, in serve_media http_tunnels = str(http_tunnel) UnboundLocalError: local variable 'http_tunnel' referenced before assignment

With this version I got googlecontroller==5.5.6 172.25.0.2 Traceback (most recent call last): File "./test.py", line 7, in home.serve_media("HappyBirthdaySong.mp3", "/home/scripts") File "/home/busybox/.local/lib/python3.7/site-packages/googlecontroller/init.py", line 42, in serve_media spliced = http_tunnels.split('"')[1] IndexError: list index out of range

Also say is also not working. Im using docker in my environment

dray-cyber commented 3 years ago

Hmmm with all that it just seems like a pip issue.all those errors relate to pyngrok.Can you try running it outside of docker?

peterd550 commented 3 years ago

Ok np I will do let you know how I go? Where are you based? Melbourne Australia 😄

dray-cyber commented 3 years ago

Ah Colorado, say command is a easy fix had converted it to a test command

dray-cyber commented 3 years ago

There you go version 5.6!

dray-cyber commented 3 years ago

There you go version 5.6 Reinstall it and say should work now!

dray-cyber commented 3 years ago

@peterd550 I also fixed the volume command by the way!

dray-cyber commented 3 years ago

Release 5.6.5 is the patch of it

peterd550 commented 3 years ago

I tried to install them on my Raspberry Pi 4 runing pip3 install googlecontroller==5.6.5 and I get this 127.0.1.1 Traceback (most recent call last): File "./test.py", line 7, in home.serve_media("HappyBirthdaySong.mp3", "/home/scripts") File "/home/pi/.local/lib/python3.7/site-packages/googlecontroller/init.py", line 42, in serve_media spliced = http_tunnels.split('"')[1] IndexError: list index out of range

from docker I the same error

dray-cyber commented 3 years ago

Hmmm, either its a ip error, pyngrok, or python version not being right. I'm running on 3.9 with windows.I do have a raspi but can not test for a little while...Also your completely sure its the FULL path?

peterd550 commented 3 years ago

I have tried it different versions of pyngrok and get the same errror Traceback (most recent call last): File "./test.py", line 7, in home.serve_media("HappyBirthdaySong.mp3", "/home/scripts") File "/home/busybox/.local/lib/python3.7/site-packages/googlecontroller/init.py", line 42, in serve_media spliced = http_tunnels.split('"')[1] IndexError: list index out of range

dray-cyber commented 3 years ago

I have tried it different versions of pyngrok and get the same errror Traceback (most recent call last): File "./test.py", line 7, in home.serve_media("HappyBirthdaySong.mp3", "/home/scripts") File "/home/busybox/.local/lib/python3.7/site-packages/googlecontroller/init.py", line 42, in serve_media spliced = http_tunnels.split('"')[1] IndexError: list index out of range

Ah I meant version of python, I am currently trying with 3.9 and succeeding.

dray-cyber commented 3 years ago

Oh my lord I see the issue

dray-cyber commented 3 years ago

home.serve_media("HappyBirthdaySong.mp3", "/home/scripts", opentunnel = 0) For the first time you must add that 3rd variable to open the pyngrok tunnel

dray-cyber commented 3 years ago

Never after though...

dray-cyber commented 3 years ago

That's the only issue, it didn't Initialize pyngrok, simple error!

peterd550 commented 3 years ago

OK I have the say working now My code is

!/usr/bin/env python3

from googlecontroller import GoogleAssistant

host = "10.0.0.1" #again your google homes ip home = GoogleAssistant(host=host) home.say("test") home.serve_media("HappyBirthdaySong.mp3", "/home/scripts", opentunnel = 0)

I have exposed port 80 in my Dockerfile. I am running once and I download the mp3 172.21.0.2 sh: 1: cmd: not found You are all set now! https://8d4a-155-143-180-128.ngrok.io/HappyBirthdaySong.mp3 t=2021-09-14T14:38:48+1000 lvl=warn msg="failed to open private leg" id=7c9571ac8ff8 privaddr=localhost:80 err="dial tcp 127.0.0.1:80: connect: connection refused"

The 2nd time 172.21.0.2 sh: 1: cmd: not found You are all set now! https://a1d3-155-143-180-128.ngrok.io/HappyBirthdaySong.mp3 t=2021-09-14T14:39:18+1000 lvl=warn msg="failed to open private leg" id=e09c2aad9d3f privaddr=localhost:80 err="dial tcp 127.0.0.1:80: connect: connection refused"

I dont know what this is sh: 1: cmd: not found

peterd550 commented 3 years ago

Any idea? Is there a pip3 install to new?

dray-cyber commented 3 years ago

Actually no idea

dray-cyber commented 3 years ago

Maybe the raspi local ip is different from 127.0.0.1...I honestly can't think atm I'll try it on a pi sometime this next week

peterd550 commented 3 years ago

127.0.0.1 is local host

dray-cyber commented 3 years ago

Wait why is your Google homes ip like that?If you have a phone go to the app click the home settings, device info.The ip should look like 192.168.0.123 or something.

dray-cyber commented 3 years ago

That's a stupid thing I just said, because say does work.But do try to replace it with something similar to that! Just for curiositys sake

peterd550 commented 3 years ago

My IP Range is 10.0.0.1 to 10.0.0.255

dray-cyber commented 3 years ago

Yeah I know, the say command works so that is fine. Although I do not know if pyngrok is struggling or what

dray-cyber commented 3 years ago

You could remove the pyngrok part in init py and replace it with a new link from pyngrok running in a separate terminal on the pi. Just try to run pyngrok generally, even a sample script

dray-cyber commented 3 years ago

See if that works, if it doesn't that is a issue.

peterd550 commented 3 years ago

Im not sure what you wanted me to do I did RUN pip3 install googlecontroller RUN pip3 install pyngrok

and got 172.19.0.2 sh: 1: cmd: not found You are all set now! https://e9a4-155-143-180-128.ngrok.io/HappyBirthdaySong.mp3 t=2021-09-29T18:30:49+1000 lvl=warn msg="failed to open private leg" id=0a11ff9031fb privaddr=localhost:80 err="dial tcp 127.0.0.1:80: connect: connection refused"

Im running this and the say works

!/usr/bin/env python3

from googlecontroller import GoogleAssistant

host = "10.0.0.1" #again your google homes ip home = GoogleAssistant(host=host) home.say("test") home.serve_media("HappyBirthdaySong.mp3","/home/scripts",opentunnel = 0)

dray-cyber commented 3 years ago

Ok that's good I think

dray-cyber commented 3 years ago

Very good actually this part right here seems to be the issue then.

def httpserver(path):
    os.chdir(path)
    os.system('cmd /k "python -m http.server 80 --bind 127.0.0.1"')
dray-cyber commented 3 years ago

Can you run this?

import os
os.system('cmd /k "python -m http.server 80 --bind 127.0.0.1"')
dray-cyber commented 3 years ago

I believe that may be the issue, you might have to go into the init.py file in your modules folder for python. Then replace http.server with SimpleHTTPServer caps do matter!

dray-cyber commented 3 years ago

Sorry for not seeing that sooner, keep forgetting your running on a raspi not windows. I'll write a patch that works for both not soon though do what is in previous comment.

peterd550 commented 3 years ago

Ok thanks Please let me know when 😀

dray-cyber commented 3 years ago

Not gonna be for a little while but you can just change that simple line in init.py in the googlecontroller folder in the python modules directory! Lemme know if you get it working.

dray-cyber commented 3 years ago

Patch is done uploading to pypi in a few hours