shivasiddharth / GassistPi

Google Assistant for Single Board Computers
Other
1.02k stars 303 forks source link

Feature requests #20

Open aceycv8 opened 7 years ago

aceycv8 commented 7 years ago

Hi,

Is it possible to add music streaming like in? https://www.hackster.io/vvanhee/internet-streaming-radio-with-google-aiy-1edff3

Pancer1 commented 6 years ago

@shivasiddharth No, this is not from config files. This is from IFTTT web page where You can configure actions to be executed on remote Home Assistant. Did You use IFTTT any time? This is kind of interface between Google Assistant and any Application with REST api (listens for Google Assistant request and anfter getting it sends URI that You configured to remote App REST api (for for example Home Assistant). I think this is what You are looking for. Here You have link with example (Google Assistant--IFTTT--Home Assistant): https://community.home-assistant.io/t/how-to-integrate-google-assistant-and-home-assistant-api-using-only-ifttt/19269

image

If You have any questions, give me a sign.

By the way, I just updated GassistPi (great job to You!) and need to set a Google Assistant speaking louder but now saing "volume up" is not working. I think this is because of You have implemented volume control by voice. Is another way to configure Google Assistant volume?

shivasiddharth commented 6 years ago

@Pancer1 , thanks for the pointers. I am aware of IFTTT, but not familioar with HA. Try the command "Set volume to maximum". My volume implementation affects only the media content. I have fixed the trigger word for that as "music volume" so both the controls are independent.

shivasiddharth commented 6 years ago

Have updated the project with Sonoff-Tasmota control, check it out. Will add the IFTTT json posting in the next.

Enzoinventor commented 6 years ago

it would be nice to create an action to play our mp3s from usb without using kodi but directly from our box assistant

VinceW31 commented 6 years ago

Get Google Music to play any Playlist by saying its Name (eg play my "Air Guitar" playlist) plus, when a new Playlist is started then start again at Track 1:

              if 'playlist'.lower() in phrase:

check to see if playlist.JSON file exists

                    track_ids=[]
                    if os.path.isfile("/home/pi/playlist.json"):
                        with open('/home/pi/playlist.json','r') as input_file:
                            playlistcontents= json.load(input_file)

if not then create it

                        playlistcontents=api.get_all_user_playlist_contents()
                        with open('/home/pi/playlist.json', 'w') as output_file:
                            json.dump(playlistcontents, output_file)

then open json file and find all playlist names:

                    with open('/home/pi/playlist.json') as json_data:   
                        f = json.load(json_data)    
                    string = str(f)
                    response = re.compile(r"name': '.*?([\s\w]+)")
                    name = response.findall(string)

try to match voice command with JSON playlist names

                    for n in range(0,len(name)):
                        Playlist_name = str(name[n])
                        print("Playlist ", n+1, " is ", str(name[n]))
                    for n in range(0,len(name)):
                        Playlist_name = str(name[n])
                        match_playlist = 0
                        if match_playlist==0:

If playlist name is matched, then play it

                            if Playlist_name.lower() in phrase:
                                match_playlist=1
                                print("\nPlaying Playlist - ", n+1, Playlist_name,)
                                os.system('echo "play_playlist(0)\n" >> /home/pi/GassistPi/src/trackchange.py')
                                say("Playing songs from your " + Playlist_name + " playlist")
                                play_playlist(n)

plus:

old_playlist_num = 100

def play_playlist(playlistnum):
    global old_playlist_num  ### define this earlier, eg old_playlist_num = 100
    new_playlist_num = playlistnum
    print("New Playlist Number is ", playlistnum)
    if os.path.isfile("/home/pi/.gmusicplaylistplayer.json"):
        with open('/home/pi/.gmusicplaylistplayer.json','r') as input_file:
            playerinfo= json.load(input_file)
        if new_playlist_num == old_playlist_num:
            currenttrackid=playerinfo[0]
            loopstatus=playerinfo[1]
            nexttrackid=currenttrackid+1 
        else:
            currenttrackid=0
            loopstatus=playerinfo[1]
            nexttrackid=currenttrackid+1 
        old_playlist_num = new_playlist_num
        playerinfo=[nexttrackid,loopstatus]
        with open('/home/pi/.gmusicplaylistplayer.json', 'w') as output_file:
            json.dump(playerinfo, output_file)
    else:
        currenttrackid=0
        nexttrackid=1
        loopstatus='on'
        playerinfo=[nexttrackid,loopstatus]
        with open('/home/pi/.gmusicplaylistplayer.json', 'w') as output_file:
            json.dump(playerinfo, output_file)

tracks,numtracks=loadplaylist(playlistnum)
startingvol=mpvvolmgr()

etc.........the rest is the same

bobjwatts commented 6 years ago

Awesome project, i have been tinkering for a few weeks, many fun times had. Would it be possible to play a specific song from Google Music - "Play about a girl by nirvana" for example?

aandroide commented 6 years ago

I had in mind to create this function for the download but I can not make it work if 'download'.lower() in str(usrcmd).lower(): os.system('youtube-dl --extract-audio --audio-format mp3'/home/pi/youtubeurllist.json) return continue_conversation

davide-casaneve commented 6 years ago

Hi, I love your project but I'd like a new function: voice match. It is already installed in google Home infact it's used by all my family so I'dlike to extend its' functions using a raspberry pi 3 with your project but now I can use only one account. Thanks for reading