From 7d07168c0d866ce6de7b26a78c76725947e0e359 Mon Sep 17 00:00:00 2001 From: Thomas Hori / Harriet Riddle Date: Sun, 20 Mar 2016 14:43:27 +0000 Subject: [PATCH 1/3] Add support for using espeak when pico2wave not available. --- README.md | 4 +++- shuffle.py | 35 +++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) 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..748c143 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 @@ -94,9 +102,17 @@ class Text2Speech(object): text = unicode(text, 'utf-8') lang = Text2Speech.guess_lang(text) if lang == "ru-RU": - return Text2Speech.rhvoice(out_wav_path, text) + if Text2Speech.valid_tts['RHVoice']: + return Text2Speech.rhvoice(out_wav_path, text) + else: + return False else: - return Text2Speech.pico2wave(out_wav_path, text) + if Text2Speech.valid_tts['pico2wave']: + return Text2Speech.pico2wave(out_wav_path, text) + elif Text2Speech.valid_tts['espeak']: + return Text2Speech.espeak(out_wav_path, text) + else: + return False # guess-language seems like an overkill for now @staticmethod @@ -113,6 +129,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", "-w", out_wav_path, unicodetext]) + return True + @staticmethod def rhvoice(out_wav_path, unicodetext): if not Text2Speech.valid_tts['RHVoice']: @@ -399,7 +422,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 From dd368a52661e631977683e6bbc3bcdc9cc091ff2 Mon Sep 17 00:00:00 2001 From: Nimesh Ghelani Date: Thu, 24 Mar 2016 21:45:50 +0530 Subject: [PATCH 2/3] redundant conditions removed --- shuffle.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/shuffle.py b/shuffle.py index 748c143..19c8af2 100755 --- a/shuffle.py +++ b/shuffle.py @@ -102,15 +102,12 @@ class Text2Speech(object): text = unicode(text, 'utf-8') lang = Text2Speech.guess_lang(text) if lang == "ru-RU": - if Text2Speech.valid_tts['RHVoice']: - return Text2Speech.rhvoice(out_wav_path, text) - else: - return False + return Text2Speech.rhvoice(out_wav_path, text) else: - if Text2Speech.valid_tts['pico2wave']: - return Text2Speech.pico2wave(out_wav_path, text) - elif Text2Speech.valid_tts['espeak']: - return Text2Speech.espeak(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 From d3c01a569334ad7304b30967be865a1a44fc10c5 Mon Sep 17 00:00:00 2001 From: Nimesh Ghelani Date: Fri, 25 Mar 2016 04:51:00 +0530 Subject: [PATCH 3/3] espeak: lowered wpm, default wpm too fast for voiceover --- shuffle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shuffle.py b/shuffle.py index 19c8af2..883a8b2 100755 --- a/shuffle.py +++ b/shuffle.py @@ -130,7 +130,7 @@ class Text2Speech(object): def espeak(out_wav_path, unicodetext): if not Text2Speech.valid_tts['espeak']: return False - subprocess.call(["espeak", "-v", "english_rp", "-w", out_wav_path, unicodetext]) + subprocess.call(["espeak", "-v", "english_rp", "-s", "150", "-w", out_wav_path, unicodetext]) return True @staticmethod