Open dayer4b opened 3 years ago
I have found a way to fix that let me submit a change request.
I have no honest clue on how to do this so Im going to paste the new code here for the file init.py
import pychromecast
name = "googlehomepush"
__all__ = (
'GoogleHome',
)
class GoogleHome:
"""
Create a Google home (an host or a devicename is mandatory)
:param devicename: string : the ip or device name of the Google Home
:param host: the host of google home
:param port: the port to contact google home by ip (default is 8009)
:param ttsbuilder: function: the tts function. This is a function who have two parameter a text string and the lang. This function return an url to download mp3 file
"""
def __init__(self, devicename = None, host = None, port = None):
if devicename != None:
chromecasts = pychromecast.get_chromecasts()
filteredChromeCast = filter(lambda c: c.host == devicename or c.device.friendly_name == devicename , chromecasts)
try:
self.cc = next(filteredChromeCast)
except StopIteration:
availbale_devices = list(map(lambda c: c.device.friendly_name, chromecasts))
raise ValueError('Unable to found %s device. Available devices : %s'%(devicename, availbale_devices))
elif host != None:
self.cc = pychromecast.Chromecast(host, port)
else:
raise ValueError('host or devicename is mandatory to create a GoogleHome object.')
def say(self, text, lang = 'en-US'):
url = u"https://translate.google.com/translate_tts?ie=UTF-8&q=" + text + "%21&tl=" + lang + "&ttsspeed=1&total=1&idx=0&client=tw-ob&textlen=14&tk=594228.1040269"
self.play(url)
def play(self, url, contenttype = 'audio/mp3'):
self.cc.wait()
mc = self.cc.media_controller
mc.play_media(url, contenttype)
mc.block_until_active()
print("played url " + url)
This may not be the best way to rewrite the tts script but it works very well for me atleast.
Anyways Its locked to English I am going to go write a fix for that right now.
Alright wrote a fix edited the last comment accordingly.Side note this renders the rest of the tts files worthless.Let me know if this helps!
thanks i'll try it!
btw, to make a pull request in Github, it's probably simplest for you to follow the Forking Workflow. To do that, fork the repo and then commit the changes to your version. You can then create a Pull Request on this repo from your fork.
I figured it out a while ago thanks though! Works right?
Also I figured out some more code to enable it to accept audio controls.
also some speed for the audio
check my fork/pull request if you care
your fork worked great! I switched to your library. FYI, in your README.md
you mention that pip install
doesn't work yet. You may not have your package on PyPi, but you can still pip install
from git sources. Example:
pip install git+https://github.com/dray-cyber/googlehomepush-v2@a35d948ae8d253a58dedc9df94abb8fb680e0e80
your fork worked great! I switched to your library. FYI, in your
README.md
you mention thatpip install
doesn't work yet. You may not have your package on PyPi, but you can stillpip install
from git sources. Example:pip install git+https://github.com/dray-cyber/googlehomepush-v2@a35d948ae8d253a58dedc9df94abb8fb680e0e80 Thats absolutely awesome I forgot about that thank you!
Can you not merge the code to master ? Can you then update your python page?
This did not work for me
pip install git+https://github.com/dray-cyber/googlehomepush-v2@a35d948ae8d253a58dedc9df94abb8fb680e0e80
This did not work for me
pip install git+https://github.com/dray-cyber/googlehomepush-v2@a35d948ae8d253a58dedc9df94abb8fb680e0e80
i believe you need git installed but I may be wrong anyways I also have a new google controller package that you can copy and paste in the sitepackages folder of python
Thanks I have it installed I'm using docker
Do you have this as a pip install?
Thanks I have it installed I'm using docker
Do you have this as a pip install?
Not yet Im working on uploading this to pypy
pypi*
alr done do pip install googlecontroller in the future
Thanks will try it out 😄
Thanks Works well
I haven't had a chance to test other features of this library, but "say" seems to no longer work. I believe it may be due to the API changes around gTTS. It seems like gTTS-token is now deprecated and the functionality is no longer necessary.
https://github.com/Boudewijn26/gTTS-token/blob/master/docs/november-2020-translate-changes.md
This suggests that libraries that are using this need to be updated to follow the new method.