Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lyrics translation using Microsoft Bing API #1939

Merged
merged 12 commits into from
Apr 14, 2016

Conversation

Kraymer
Copy link
Contributor

@Kraymer Kraymer commented Apr 13, 2016

🌐 Adiou,

Dunno if it should be merged or if I should maintain it separately in my fork : scratching my own hitch here, and the result of translation can be suboptimal.

  • fix pep8 warnings on existing code
  • add config option to restrict the translation feature to few langages
  • documentation
  • detect when token expired and get a new one
  • use a set to reduce size of text to translate and thus translate more songs within the fixed API limit of 2,000,000 chars/month

lyrics: fetched lyrics: João Gilberto - Amoroso/Brasil - Aquarela do Brasil (Watercolour Painting of Brazil)
Brasil! / Brazil! 
Meu Brasil Brasileiro /  My Brazilian Brazil 
Meu mulato inzoneiro /  My creamy inzoneiro 
Vou cantar-te nos meus versos /  I will sing you my verses 
Brasil, samba que dá /  Brazil, samba gives 
Bamboleio, que faz gingar /  Wiggle, which makes waddle 
O Brasil do meu amor /  The Brazil of my love 
Terra de Nosso Senhor... /  Land of our Lord ... 

[...]

By subscribing to Microsoft Translator API, one can now activate the
translation of lyrics from one set of source langages to a target
langage.
Translations are appended to each original sentence using ‘/‘ as
separator.
@@ -113,3 +121,19 @@ After that, the lyrics plugin will fall back on other declared data sources.

.. _pip: http://www.pip-installer.org/
.. _BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/bs4/doc/

Activate on-the-fly translation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching our usual style, this should probably be in Title Case: "Activate On-the-Fly Translation"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sampsyo
Copy link
Member

sampsyo commented Apr 14, 2016

This is pretty nifty! I'm all for it—it's a fairly "niche" feature, but that's true of a great many of beets' features. 😃

Bing API has a limit of 2M chars/month. It’s common to have repeating
sentences in lyrics so to reduce number of chars sent per song, store
sentences in a set and send it, instead of sending the whole lyrics.
@Kraymer
Copy link
Contributor Author

Kraymer commented Apr 14, 2016

👻 Good to merge?

@sampsyo
Copy link
Member

sampsyo commented Apr 14, 2016

Looks great! Go for it!

@Kraymer Kraymer merged commit a282245 into beetbox:master Apr 14, 2016
@Kraymer Kraymer deleted the lyrics_translate branch April 14, 2016 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants