diff --git a/README.md b/README.md index 8e1d133..3d3067f 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,10 @@ Original data can be found via [wayback machine](https://web.archive.org/web/201 # License and Copyright ``` -Copyright (c) 2012-2016 ikelos, nims11, NicoHood +Copyright (c) 2012-2016 ikelos, nims11, ahippo, NicoHood, Thomas Hori See the readme for credit to other people. +This software falls at least partly under the GNU GPL v2. Certain portions +fall under the following terms: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/shuffle.py b/shuffle.py index d1cc202..883a8b2 100755 --- a/shuffle.py +++ b/shuffle.py @@ -51,13 +51,14 @@ def validate_unicode(path): def exec_exists_in_path(command): with open(os.devnull, 'w') as FNULL: try: - subprocess.call([command], stdout=FNULL, stderr=subprocess.STDOUT) - return True + with open(os.devnull, 'r') as RFNULL: + subprocess.call([command], stdout=FNULL, stderr=subprocess.STDOUT, stdin=RFNULL) + return True except OSError as e: return False class Text2Speech(object): - valid_tts = {'pico2wave': True, 'RHVoice': True} + valid_tts = {'pico2wave': True, 'RHVoice': True, 'espeak': True} @staticmethod def check_support(): @@ -70,6 +71,13 @@ class Text2Speech(object): else: voiceoverAvailable = True + # Check for espeak voiceover + if not exec_exists_in_path("espeak"): + Text2Speech.valid_tts['espeak'] = False + print "Error executing espeak, voicever won't be generated using it." + else: + voiceoverAvailable = True + # Check for Russian RHVoice voiceover if not exec_exists_in_path("RHVoice"): Text2Speech.valid_tts['RHVoice'] = False @@ -96,7 +104,12 @@ class Text2Speech(object): if lang == "ru-RU": return Text2Speech.rhvoice(out_wav_path, text) else: - return Text2Speech.pico2wave(out_wav_path, text) + if Text2Speech.pico2wave(out_wav_path, text): + return True + elif Text2Speech.espeak(out_wav_path, text): + return True + else: + return False # guess-language seems like an overkill for now @staticmethod @@ -113,6 +126,13 @@ class Text2Speech(object): subprocess.call(["pico2wave", "-l", "en-GB", "-w", out_wav_path, unicodetext]) return True + @staticmethod + def espeak(out_wav_path, unicodetext): + if not Text2Speech.valid_tts['espeak']: + return False + subprocess.call(["espeak", "-v", "english_rp", "-s", "150", "-w", out_wav_path, unicodetext]) + return True + @staticmethod def rhvoice(out_wav_path, unicodetext): if not Text2Speech.valid_tts['RHVoice']: @@ -399,7 +419,7 @@ class Playlist(Record): def set_master(self, tracks): # By default use "All Songs" builtin voiceover (dbid all zero) # Else generate alternative "All Songs" to fit the speaker voice of other playlists - if self.voiceover and Text2Speech.valid_tts['pico2wave']: + if self.voiceover and (Text2Speech.valid_tts['pico2wave'] or Text2Speech.valid_tts['espeak']): self["dbid"] = hashlib.md5("masterlist").digest()[:8] #pylint: disable-msg=E1101 self.text_to_speech("All songs", self["dbid"], True) self["listtype"] = 1