GithubHelp home page GithubHelp logo

github30 / pichromecast Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 3.0 34 KB

Library for MicroPython to communicate with the Google Chromecast.

Home Page: https://pypi.org/project/pichromecast

License: MIT License

Python 100.00%
chromecast internet-of-things micropython python raspberry-pi raspberry-pi-pico-rp2040 raspberry-pi-pico-w cast chromecast-audio pypi

pichromecast's Introduction

Python PyPI

PiChromecast

Library for MicroPython to communicate with the Google Chromecast.

Install

Tools > Manage packages...

image

or copy and paste code

https://github.com/GitHub30/pichromecast/blob/main/pichromecast.py

Usage

from pichromecast import play_url

play_url('https://nyanpass.com/nyanpass.mp3', '192.168.10.101')

Text to Speech

from pichromecast import play_url, create_url

play_url(create_url('hello world', 'en'), '192.168.10.101')
# https://gist.github.com/SpotlightKid/eca9b00239104e8c599b86635f62ab73#file-urlencode-py
from urlencode import urlencode
from pichromecast import play_url

url = 'https://translate.google.com/translate_tts?client=tw-ob&' + urlencode({'q': 'Hello, 世界', 'tl': 'ja'})
play_url(url, '192.168.10.101')

Connect wifi and play

import network
import time

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("aterm-SSID-g", "YOUR_PASSWORD")
while not wlan.isconnected() and wlan.status() >= 0:
    print("Waiting to connect:")
    time.sleep(1)


from pichromecast import play_url

play_url('https://nyanpass.com/nyanpass.mp3', '192.168.10.101')

image

Lookup host IP

#pip install pychromecast
import pychromecast

services, browser = pychromecast.discovery.discover_chromecasts()
pychromecast.discovery.stop_discovery(browser)
print(services)
[CastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-3b0a32dc5803130351919f8a286e406f._googlecast._tcp.local.')}, uuid=UUID('3b0a32dc-5803-1303-5191-9f8a286e406f'), model_name='Google Home Mini', friendly_name='書斎', host='192.168.10.101', port=8009, cast_type='audio', manufacturer='Google Inc.')]

or use MicroPython MDNS

Demo

Watch the video

pichromecast's People

Contributors

github30 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pichromecast's Issues

Casting to google group

I have multiple google speakers.

When I create a group, I see that the ip address for the group speaker is the same at one of the individual speakers.

Is there a way to cast to the speaker group? or is this limited to one google speaker?

Pychromecast is able to cast to a group based on the friendly name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.