mirror of
https://github.com/nims11/IPod-Shuffle-4g.git
synced 2025-12-07 16:08:00 +09:00
Merge branch 'thomas-hori-pullable'
This commit is contained in:
commit
dd1bc56542
2 changed files with 28 additions and 6 deletions
|
|
@ -133,8 +133,10 @@ Original data can be found via [wayback machine](https://web.archive.org/web/201
|
||||||
# License and Copyright
|
# 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.
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
30
shuffle.py
30
shuffle.py
|
|
@ -51,13 +51,14 @@ def validate_unicode(path):
|
||||||
def exec_exists_in_path(command):
|
def exec_exists_in_path(command):
|
||||||
with open(os.devnull, 'w') as FNULL:
|
with open(os.devnull, 'w') as FNULL:
|
||||||
try:
|
try:
|
||||||
subprocess.call([command], stdout=FNULL, stderr=subprocess.STDOUT)
|
with open(os.devnull, 'r') as RFNULL:
|
||||||
return True
|
subprocess.call([command], stdout=FNULL, stderr=subprocess.STDOUT, stdin=RFNULL)
|
||||||
|
return True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class Text2Speech(object):
|
class Text2Speech(object):
|
||||||
valid_tts = {'pico2wave': True, 'RHVoice': True}
|
valid_tts = {'pico2wave': True, 'RHVoice': True, 'espeak': True}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_support():
|
def check_support():
|
||||||
|
|
@ -70,6 +71,13 @@ class Text2Speech(object):
|
||||||
else:
|
else:
|
||||||
voiceoverAvailable = True
|
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
|
# Check for Russian RHVoice voiceover
|
||||||
if not exec_exists_in_path("RHVoice"):
|
if not exec_exists_in_path("RHVoice"):
|
||||||
Text2Speech.valid_tts['RHVoice'] = False
|
Text2Speech.valid_tts['RHVoice'] = False
|
||||||
|
|
@ -96,7 +104,12 @@ class Text2Speech(object):
|
||||||
if lang == "ru-RU":
|
if lang == "ru-RU":
|
||||||
return Text2Speech.rhvoice(out_wav_path, text)
|
return Text2Speech.rhvoice(out_wav_path, text)
|
||||||
else:
|
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
|
# guess-language seems like an overkill for now
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -113,6 +126,13 @@ class Text2Speech(object):
|
||||||
subprocess.call(["pico2wave", "-l", "en-GB", "-w", out_wav_path, unicodetext])
|
subprocess.call(["pico2wave", "-l", "en-GB", "-w", out_wav_path, unicodetext])
|
||||||
return True
|
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
|
@staticmethod
|
||||||
def rhvoice(out_wav_path, unicodetext):
|
def rhvoice(out_wav_path, unicodetext):
|
||||||
if not Text2Speech.valid_tts['RHVoice']:
|
if not Text2Speech.valid_tts['RHVoice']:
|
||||||
|
|
@ -399,7 +419,7 @@ class Playlist(Record):
|
||||||
def set_master(self, tracks):
|
def set_master(self, tracks):
|
||||||
# By default use "All Songs" builtin voiceover (dbid all zero)
|
# By default use "All Songs" builtin voiceover (dbid all zero)
|
||||||
# Else generate alternative "All Songs" to fit the speaker voice of other playlists
|
# 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["dbid"] = hashlib.md5("masterlist").digest()[:8] #pylint: disable-msg=E1101
|
||||||
self.text_to_speech("All songs", self["dbid"], True)
|
self.text_to_speech("All songs", self["dbid"], True)
|
||||||
self["listtype"] = 1
|
self["listtype"] = 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue