stevenleeg / geemusic

A bridge between Google Music and Amazon's Alexa
GNU General Public License v3.0
662 stars 178 forks source link

Usage with other languages #173

Closed simonszu closed 6 years ago

simonszu commented 6 years ago

Hi,

i have some basic skills with developing skills for the Echo. I think it could be possible to adapt your bridge for other languages, but at first, i need to know how language-agnostic the bridge daemon is. I have not checked it for myself, yet, but does it report other things than music back to the Alexa service?

My idea is to just change the utterances in the AWS skill settings, so that Alexa knows how to handle german utterances (i am from germany), and if your bridge just reports back the music to the device, all would be fine. However, the Amazon Music integration for Alexa makes Alexa say something, like a radio moderator, for example: "Alexa, play me some Metallica music" - "Here is some Metallica music ".

I think it would be weird, if a german voice model tries to speak english words...but could it be generally possible?

fergyfresh commented 6 years ago

You could definitely do it with this repository here without changing too much. You would need to make a German version of the https://github.com/stevenleeg/geemusic/blob/master/speech_assets/sampleUtterances.txt on a branch on your fork. The second thing we would have to do is some sort or YAML files with all the strings for every function or what I would like to do is just a Python dictionary that we put at the top of each file with the English/German versions of each string and we could add an environment variable for what language you want to use.

So instead of the code below you would substitute all of the English phrases for german phrases and then eventually we would need to use the dictionary/YAML method for swapping between languages. So the quick and dirty approach is to translate all of the English phrases in the selection.py file and modify all of the speech assets to be German.

You could do a relatively simple test by only changing a few things:

Make a fork and modify the sampleUtterances.txt file lines below after GeeMusicPlayThumbsUpIntent to be German so that your German Alexa knows what you're saying.

79 GeeMusicPlayThumbsUpIntent Play promoted songs 
80 GeeMusicPlayThumbsUpIntent Play up voted songs 
81 GeeMusicPlayThumbsUpIntent Play thumbs up songs 

The code that goes with the Intent above is in selection.py and you'd have to modify the English strings on lines 88, 92, and 98 to German.

86 @ask.intent("GeeMusicPlayThumbsUpIntent") 
87 def play_promoted_songs(): 
88     app.logger.debug("Fetching songs that you have up voted.") 
89      
90     promoted_songs = api.get_promoted_songs() 
91     if promoted_songs is False: 
92         return statement("Sorry, I couldnt find any up voted songs.") 
93      
94     first_song_id = queue.reset(promoted_songs) 
95     stream_url = api.get_stream_url(first_song_id) 
96 

97     thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url']) 
98     speech_text = "Playing your upvoted songs." 
99     return audio(speech_text).play(stream_url) \ 
100         .standard_card(title=speech_text, 
101                        text='', 
102                        small_image_url=thumbnail, 
103                        large_image_url=thumbnail)    

I hope this works and if it doesn't work it probably has something to do with the fact that I don't know how to tell Alexa if an app is German or English, but either way you should try what I suggested above and test it out and come back with the results, we can work through this.

simonszu commented 6 years ago

OK, cool. I need some time, because i have canceled my Amazon Music Unlimited subscription just now, and first need to set up my GMusic account and transfer all the music...but i'll come back to this project. Just leave this issue open, i'll let you know if i have proceeded.

fergyfresh commented 6 years ago

Well lets see here buddy, I have some time this weekend so if you can reply to this with the translations for the things I mentioned above and possibly a soundcloud link or some other audio clip linking website I could see if I could do it the trial for you this weekend.

simonszu commented 6 years ago

I think I should at least create the data for you, the utterances and the translations in the code. What do you need SoundCloud for?

On Fri, Feb 2, 2018, 22:28 Billy Ferguson notifications@github.com wrote:

Well lets see here buddy, I have some time this weekend so if you can reply to this with the translations for the things I mentioned above and possibly a soundcloud link or some other audio clip linking website I could see if I could do it the trial for you this weekend.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/stevenleeg/geemusic/issues/173#issuecomment-362712874, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqxIznROEbtkvPZD0cVFFaZtWi4XgvSks5tQ334gaJpZM4R3mgh .

-- Before printing this email, think if it is really needed.

fergyfresh commented 6 years ago

So i could test it haha, i speak pretty shitty German.

fergyfresh commented 6 years ago

174 and #175 I have started with what I was talking about with my big comment on this issue. Check out the code in my master branch. In the playback.py file I would like you to add all the German translations under de following the same dictionary setup for the en one. Same thing with the Japanese one. If you want to use a language other than English (en) you'll have to specify an environment variable LANGUAGE=de for German for example.

https://github.com/fergyfresh/geemusic/blob/master/geemusic/intents/playback.py And if either of you want to take over what I did on line 62 of the link above that would be awesome. On your first pull request to MY FORK, I want you to fill out the scaffolding that I set up for your language of choice. Secondly, if either of you want to finish the refactoring of changing all the strings to their proper lookups that would be great. I can do it too if you guys don't get to it though.

simonszu commented 6 years ago

There is some great progress here. I had another idea for the future: Defining more than one response for a certain intent, and let a randomizer decide which one is selected for sending to Alexa. This ensures a more natural user experience, since a human DJ would vary his anwers as well, when being asked to play a certain song, like "Yes", "Okay", "Good idea". Maybe you have the Philips Hue skill enabled, then you know what i mean - the only anwer Alexa responds when being asked to switch on/off a light is "Okay" which is not quite cool.

fergyfresh commented 6 years ago

checkout #179

fergyfresh commented 6 years ago

Close this with the merge of #179, unless you wanna keep it open for informational purposes.