diff --git a/RPI Code/blinkpy b/RPI Code/blinkpy new file mode 160000 index 0000000..79ead7b --- /dev/null +++ b/RPI Code/blinkpy @@ -0,0 +1 @@ +Subproject commit 79ead7b826bb09b95fc0197113515a662ce76acb diff --git a/RPI Code/googleHome/hello_world_ja.mp3 b/RPI Code/googleHome/hello_world_ja.mp3 new file mode 100644 index 0000000..aaf9fba Binary files /dev/null and b/RPI Code/googleHome/hello_world_ja.mp3 differ diff --git a/RPI Code/googleHome/test-home.py b/RPI Code/googleHome/test-home.py new file mode 100644 index 0000000..391083e --- /dev/null +++ b/RPI Code/googleHome/test-home.py @@ -0,0 +1,22 @@ +from gtts import gTTSimport time +import pychromecast +from gtts import gTTS + +casts, browser = pychromecast.get_chromecasts() +pychromecast.discovery.stop_discovery(browser) +if len(casts) == 0: + print("No Devices Found") + sys.exit(1) + +print("Found cast devices:") +for cast in casts: + print( + ' "{}" on mDNS service {} with UUID:{}'.format( + cast.name, cast._services, cast.uuid # pylint: disable=protected-access + ) + ) + +print(casts[0]) + +tts = gTTS(text='Coucou petit asticot' , lang='fr') +tts.save('./hello_world_ja.mp3') diff --git a/RPI Code/googleHome/test-http.py b/RPI Code/googleHome/test-http.py new file mode 100644 index 0000000..3225757 --- /dev/null +++ b/RPI Code/googleHome/test-http.py @@ -0,0 +1,86 @@ +import omitted +import os.path +from bottle import route, run, static_file, template +from os import path +from flask import request +import hashlib +from gtts import gTTS +import pychromecast + + +BASE_DIR = '/home/thomas/googleHome' +TALK_DIR = '/home/thomas/googleHome/var' +#app = bottle() + +@route('/talks/') +def get_talk_mp3(file_path): + print(file_path) + print(TALK_DIR) + return static_file(file_path, root=TALK_DIR) + +@route('/form//', method='GET') +def get_talk_form(text, lang): + + "" "form display" "" + + content = BASE_DIR + '/template.html' + + text = text or '' + + lang = lang or 'ja' + + return template(content.open().read(), langs=gTTS.LANGUAGES, lang=lang, text=text) + + + +@route('/form//', method='POST') +def post_talk_form(text, lang): + + "" "Save the talk text, playback instruction" "" + + print('ceci est un tesssst') + print(text) + print(lang) + text_token = generate_talk(text, lang) + #because troublesome, beating decided to GoogleCast terminal attached to the eye + chromecasts, browser = pychromecast.get_listed_chromecasts(friendly_names=["Bureau Mini"]) + #chromecasts = pychromecast.get_chromecasts() + chromecasts[0].wait() + print(chromecasts[0].device) + cast = chromecasts[0] + print(f"http://192.168.31.140:8080/talks/{text_token}") + mc = cast.media_controller + mc.play_media(f"http://192.168.31.140:8080/talks/{text_token}", 'audio/mp3') + mc.block_until_active() + print(mc.status) + return get_talk_form(text, lang) + + + +def generate_talk(text, lang): + + "" "languages to use the cache When not match the text" "" + + text_token = hashlib.sha256((lang + text).encode()).hexdigest() + text_token+='.mp3' + talk_path = TALK_DIR+ '/' + text_token + + if not path.exists(talk_path): + + tts = gTTS(text=text, lang=lang) + + tts.save(talk_path) + print(talk_path) + + print(text_token) + return text_token + + + +if __name__ == '__main__': + + if not path.isdir(TALK_DIR): + + os.mkdir(TALK_DIR) + + run(host='0.0.0.0', port='8080', reloader=True) diff --git a/RPI Code/googleHome/var/0eed83ca6ac7741c98c4d60120ec30c305e4613149c5387c8a0eac27815df606.mp3 b/RPI Code/googleHome/var/0eed83ca6ac7741c98c4d60120ec30c305e4613149c5387c8a0eac27815df606.mp3 new file mode 100644 index 0000000..92fe4ec Binary files /dev/null and b/RPI Code/googleHome/var/0eed83ca6ac7741c98c4d60120ec30c305e4613149c5387c8a0eac27815df606.mp3 differ diff --git a/RPI Code/googleHome/var/3c0c574655e8459641dd6a937b4cd9b0be2b28b62f28dbc46712bdaff6eb74fa.mp3 b/RPI Code/googleHome/var/3c0c574655e8459641dd6a937b4cd9b0be2b28b62f28dbc46712bdaff6eb74fa.mp3 new file mode 100644 index 0000000..ee36d26 Binary files /dev/null and b/RPI Code/googleHome/var/3c0c574655e8459641dd6a937b4cd9b0be2b28b62f28dbc46712bdaff6eb74fa.mp3 differ diff --git a/RPI Code/googleHome/var/428bf747af1dd44311ea5f6632bf7bb82b212dc149f915a37489d4836e944ad4.mp3 b/RPI Code/googleHome/var/428bf747af1dd44311ea5f6632bf7bb82b212dc149f915a37489d4836e944ad4.mp3 new file mode 100644 index 0000000..7f3a673 Binary files /dev/null and b/RPI Code/googleHome/var/428bf747af1dd44311ea5f6632bf7bb82b212dc149f915a37489d4836e944ad4.mp3 differ diff --git a/RPI Code/googleHome/var/4a803e346f901897bc30bdec6cb8e5641dc4c2d4d3401cdb0897c521392a981a.mp3 b/RPI Code/googleHome/var/4a803e346f901897bc30bdec6cb8e5641dc4c2d4d3401cdb0897c521392a981a.mp3 new file mode 100644 index 0000000..9fe1f5d Binary files /dev/null and b/RPI Code/googleHome/var/4a803e346f901897bc30bdec6cb8e5641dc4c2d4d3401cdb0897c521392a981a.mp3 differ diff --git a/RPI Code/googleHome/var/524e670fcfaa2a3859aa76aa06bdfdf143a7cea5aba0cd6f8a28796c1c9e5092.mp3 b/RPI Code/googleHome/var/524e670fcfaa2a3859aa76aa06bdfdf143a7cea5aba0cd6f8a28796c1c9e5092.mp3 new file mode 100644 index 0000000..4597ce1 Binary files /dev/null and b/RPI Code/googleHome/var/524e670fcfaa2a3859aa76aa06bdfdf143a7cea5aba0cd6f8a28796c1c9e5092.mp3 differ diff --git a/RPI Code/googleHome/var/8d27aadcd9d3d22b50c2428841dbe814c25666a7be93c0a38976570b4241d8d8.mp3 b/RPI Code/googleHome/var/8d27aadcd9d3d22b50c2428841dbe814c25666a7be93c0a38976570b4241d8d8.mp3 new file mode 100644 index 0000000..90614df Binary files /dev/null and b/RPI Code/googleHome/var/8d27aadcd9d3d22b50c2428841dbe814c25666a7be93c0a38976570b4241d8d8.mp3 differ diff --git a/RPI Code/googleHome/var/95ba5bd93c80b168d05d52edba5c688fdfeca91035fa413e8a96b1817b172d13.mp3 b/RPI Code/googleHome/var/95ba5bd93c80b168d05d52edba5c688fdfeca91035fa413e8a96b1817b172d13.mp3 new file mode 100644 index 0000000..06dacbc Binary files /dev/null and b/RPI Code/googleHome/var/95ba5bd93c80b168d05d52edba5c688fdfeca91035fa413e8a96b1817b172d13.mp3 differ diff --git a/RPI Code/googleHome/var/aa65d98da37d0c4799e00fea816cefc9347a12902151c7757943ccc5c6f7f754.mp3 b/RPI Code/googleHome/var/aa65d98da37d0c4799e00fea816cefc9347a12902151c7757943ccc5c6f7f754.mp3 new file mode 100644 index 0000000..74dec78 Binary files /dev/null and b/RPI Code/googleHome/var/aa65d98da37d0c4799e00fea816cefc9347a12902151c7757943ccc5c6f7f754.mp3 differ diff --git a/RPI Code/googleHome/var/ac8d445976cd58f318cd6df2057b2aa2ea029a3f972f08322a1420a2fa036c83.mp3 b/RPI Code/googleHome/var/ac8d445976cd58f318cd6df2057b2aa2ea029a3f972f08322a1420a2fa036c83.mp3 new file mode 100644 index 0000000..f1b0026 Binary files /dev/null and b/RPI Code/googleHome/var/ac8d445976cd58f318cd6df2057b2aa2ea029a3f972f08322a1420a2fa036c83.mp3 differ diff --git a/RPI Code/googleHome/var/bca0446695dfe9d386642118a079f0073f18cd89b3a1348a2b8d608b224a687c.mp3 b/RPI Code/googleHome/var/bca0446695dfe9d386642118a079f0073f18cd89b3a1348a2b8d608b224a687c.mp3 new file mode 100644 index 0000000..e99a32a Binary files /dev/null and b/RPI Code/googleHome/var/bca0446695dfe9d386642118a079f0073f18cd89b3a1348a2b8d608b224a687c.mp3 differ diff --git a/RPI Code/googleHome/var/c071aaac32fc9514dd3dfd0f5e42308ca595d90ddd8158b921036b71c972e8d7.mp3 b/RPI Code/googleHome/var/c071aaac32fc9514dd3dfd0f5e42308ca595d90ddd8158b921036b71c972e8d7.mp3 new file mode 100644 index 0000000..2ddab78 Binary files /dev/null and b/RPI Code/googleHome/var/c071aaac32fc9514dd3dfd0f5e42308ca595d90ddd8158b921036b71c972e8d7.mp3 differ diff --git a/RPI Code/googleHome/var/c3eb41aceff5ca0def0c9088c283887b8328d604ec5a83ec37ff8b0554b1ce7d.mp3 b/RPI Code/googleHome/var/c3eb41aceff5ca0def0c9088c283887b8328d604ec5a83ec37ff8b0554b1ce7d.mp3 new file mode 100644 index 0000000..06f669f Binary files /dev/null and b/RPI Code/googleHome/var/c3eb41aceff5ca0def0c9088c283887b8328d604ec5a83ec37ff8b0554b1ce7d.mp3 differ diff --git a/RPI Code/googleHome/var/c98721254f0098fe0f56c3bd89b888d6e3dd0e858bb04de1023e6befc143afb1.mp3 b/RPI Code/googleHome/var/c98721254f0098fe0f56c3bd89b888d6e3dd0e858bb04de1023e6befc143afb1.mp3 new file mode 100644 index 0000000..c127c9d Binary files /dev/null and b/RPI Code/googleHome/var/c98721254f0098fe0f56c3bd89b888d6e3dd0e858bb04de1023e6befc143afb1.mp3 differ diff --git a/RPI Code/googleHome/var/d385c9a54d6c6506f94564e3aa7df54f208f46c64d04c77018fa3bf166303010.mp3 b/RPI Code/googleHome/var/d385c9a54d6c6506f94564e3aa7df54f208f46c64d04c77018fa3bf166303010.mp3 new file mode 100644 index 0000000..75df6c0 Binary files /dev/null and b/RPI Code/googleHome/var/d385c9a54d6c6506f94564e3aa7df54f208f46c64d04c77018fa3bf166303010.mp3 differ diff --git a/RPI Code/googleHome/var/e2ce50a6554f978d30b8ace536f0f17a30924b33621f6a500ef29c4eb5dd0eb3.mp3 b/RPI Code/googleHome/var/e2ce50a6554f978d30b8ace536f0f17a30924b33621f6a500ef29c4eb5dd0eb3.mp3 new file mode 100644 index 0000000..1ca9686 Binary files /dev/null and b/RPI Code/googleHome/var/e2ce50a6554f978d30b8ace536f0f17a30924b33621f6a500ef29c4eb5dd0eb3.mp3 differ diff --git a/RPI Code/soco/test.py b/RPI Code/soco/test.py new file mode 100644 index 0000000..90301d8 --- /dev/null +++ b/RPI Code/soco/test.py @@ -0,0 +1,63 @@ +import soco +import cgi +from soco.discovery import by_name +from soco.music_services import MusicService + +device = soco.discovery.any_soco() + +albums = device.music_library.get_albums(search_term='Black') +for album in albums: + print('Added:', album.title) +# device.add_to_queue(album) + +for zone in soco.discover(): + print(zone.player_name) + +zone_list = list(soco.discover()) +for zoneList in zone_list: + print(zoneList) + print(zoneList.player_name) + print(zoneList.volume) + +device = by_name('Bureau') +print(device) +device.volume = 5 + +device.play() +print(device.get_current_track_info()) +print(device.get_queue()) +#print(MusicService.get_subscribed_services_names()) +#spotify = MusicService('Spotify') +#print(spotify.available_search_categories) + +#print(MusicService.get_subscribed_services_names()) +#device.volume += 10 +#device.pause() + + +print(device.get_speaker_info()) +print(device.get_current_transport_info()) +#device.next() + +print(device.player_name) +print(device.get_sonos_playlists()) + +#device.play_uri('https://lasonotheque.org/UPLOAD/mp3/2249.mp3') + +#device.play() +print(device.get_current_track_info()) + +def tts(message): + key = "30b5e38e083d40b5b5637060cd3a9ef4" # replace with your real key + lang = "fr-fr" # or whatever language + freq = "44khz_8bit_mono" # Sonos cannot play the default, this one is working... + device.play_uri("x-rincon-mp3radio://api.voicerss.org/?key=%s&hl=%s&f=%s&src='%s'" %(key, lang, freq, message),title="Computer speaking - Test Thomas") +#tts('lol ctest un test') + +device.volume = 25 +#device.play_uri('https://lasonotheque.org/UPLOAD/mp3/2333.mp3') +#device.play_uri('x-sonos-spotify:spotify:track:6z2iUdxsGg0ASb4wQzwhuK?sid=9&flags=0&sn=1') +#device.play_uri('x-sonos-spotify:spotify:track:7rNjupJkjsc3ANGeW0RCYj?sid=9&flags=0&sn=1') +#device.play_uri('http://192.168.31.140:8080/talks/428bf747af1dd44311ea5f6632bf7bb82b212dc149f915a37489d4836e944ad4.mp3') +device.play_uri('http://192.168.31.140:8080/talks/0eed83ca6ac7741c98c4d60120ec30c305e4613149c5387c8a0eac27815df606.mp3') +device.play_uri('http://192.168.31.140:8080/talks/8d27aadcd9d3d22b50c2428841dbe814c25666a7be93c0a38976570b4241d8d8.mp3') diff --git a/RPI Code/soco/test.py.save b/RPI Code/soco/test.py.save new file mode 100644 index 0000000..acf6bf0 --- /dev/null +++ b/RPI Code/soco/test.py.save @@ -0,0 +1,50 @@ +import soco +import cgi +from soco.discovery import by_name +from soco.music_services import MusicService + +device = soco.discovery.any_soco() + +albums = device.music_library.get_albums(search_term='Black') +for album in albums: + print('Added:', album.title) +# device.add_to_queue(album) + +for zone in soco.discover(): + print(zone.player_name) + +zone_list = list(soco.discover()) +for zoneList in zone_list: + print(zoneList) + print(zoneList.player_name) + print(zoneList.volume) + +device = by_name('Bureau') +print(device) +device.volume = 5 + +device.play() +print(device.get_current_track_info()) +print(device.get_queue()) +#print(MusicService.get_subscribed_services_names()) +#spotify = MusicService('Spotify') +#print(spotify.available_search_categories) + +#print(MusicService.get_subscribed_services_names()) +#device.volume += 10 +#device.pause() + + +print(device.get_speaker_info()) +print(device.get_current_transport_info()) +#device.next() + +print(device.player_name) +print(device.get_sonos_playlists()) + +#device.play_uri('https://lasonotheque.org/UPLOAD/mp3/2249.mp3') + +#device.play() +print(device.get_current_track_info()) + +def tts(message):