mirror of
https://github.com/nims11/IPod-Shuffle-4g.git
synced 2025-12-07 16:08:00 +09:00
Merge 28506b0caa into a97a99ab86
This commit is contained in:
commit
464aad7e28
1 changed files with 29 additions and 7 deletions
|
|
@ -139,7 +139,7 @@ class Text2Speech(object):
|
||||||
def text2speech(out_wav_path, text):
|
def text2speech(out_wav_path, text):
|
||||||
# Skip voiceover generation if a track with the same name is used.
|
# Skip voiceover generation if a track with the same name is used.
|
||||||
# This might happen with "Track001" or "01. Intro" names for example.
|
# This might happen with "Track001" or "01. Intro" names for example.
|
||||||
if os.path.isfile(out_wav_path):
|
if os.path.isfile(out_wav_path) and os.path.getsize(out_wav_path) > 0:
|
||||||
verboseprint("Using existing", out_wav_path)
|
verboseprint("Using existing", out_wav_path)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -204,7 +204,6 @@ class Text2Speech(object):
|
||||||
os.remove(tmp_file.name)
|
os.remove(tmp_file.name)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Record(object):
|
class Record(object):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
|
|
@ -233,9 +232,24 @@ class Record(object):
|
||||||
|
|
||||||
def text_to_speech(self, text, dbid, playlist = False):
|
def text_to_speech(self, text, dbid, playlist = False):
|
||||||
if self.track_voiceover and not playlist or self.playlist_voiceover and playlist:
|
if self.track_voiceover and not playlist or self.playlist_voiceover and playlist:
|
||||||
|
p = self.parent
|
||||||
|
speakable = dict()
|
||||||
|
# find the speakable dict somewhere in the parent path
|
||||||
|
while True:
|
||||||
|
if hasattr(p, 'speakable'):
|
||||||
|
speakable = p.speakable
|
||||||
|
break
|
||||||
|
elif hasattr(p, 'parent'):
|
||||||
|
p = p.parent
|
||||||
|
else:
|
||||||
|
break
|
||||||
# Create the voiceover wav file
|
# Create the voiceover wav file
|
||||||
fn = ''.join(format(x, '02x') for x in reversed(dbid))
|
fn = ''.join(format(x, '02x') for x in reversed(dbid))
|
||||||
path = os.path.join(self.base, "iPod_Control", "Speakable", "Tracks" if not playlist else "Playlists", fn + ".wav")
|
path = os.path.join(self.base, "iPod_Control", "Speakable", "Tracks" if not playlist else "Playlists", fn + ".wav")
|
||||||
|
if path in speakable and os.path.getsize(path) > 0:
|
||||||
|
speakable[path] = True
|
||||||
|
return True
|
||||||
|
speakable[path] = True
|
||||||
return Text2Speech.text2speech(path, text)
|
return Text2Speech.text2speech(path, text)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -607,13 +621,16 @@ class Shuffler(object):
|
||||||
self.trackgain = trackgain
|
self.trackgain = trackgain
|
||||||
self.auto_dir_playlists = auto_dir_playlists
|
self.auto_dir_playlists = auto_dir_playlists
|
||||||
self.auto_id3_playlists = auto_id3_playlists
|
self.auto_id3_playlists = auto_id3_playlists
|
||||||
|
self.speakable = dict()
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
# remove existing voiceover files (they are either useless or will be overwritten anyway)
|
# make note of existing voiceover files (they can be removed if they're not referenced while writing the database)
|
||||||
for dirname in ('iPod_Control/Speakable/Playlists', 'iPod_Control/Speakable/Tracks'):
|
for dirname in ('iPod_Control/Speakable/Playlists', 'iPod_Control/Speakable/Tracks'):
|
||||||
shutil.rmtree(os.path.join(self.path, dirname), ignore_errors=True)
|
for root, dirs, files in os.walk(os.path.join(self.path, dirname)):
|
||||||
for dirname in ('iPod_Control/iTunes', 'iPod_Control/Music', 'iPod_Control/Speakable/Playlists', 'iPod_Control/Speakable/Tracks'):
|
for file in files:
|
||||||
make_dir_if_absent(os.path.join(self.path, dirname))
|
self.speakable[os.path.join(root,file)] = False
|
||||||
|
for dirname in ('iPod_Control/iTunes', 'iPod_Control/Music', 'iPod_Control/Speakable/Playlists', 'iPod_Control/Speakable/Tracks'):
|
||||||
|
make_dir_if_absent(os.path.join(self.path, dirname))
|
||||||
|
|
||||||
def dump_state(self):
|
def dump_state(self):
|
||||||
print("Shuffle DB state")
|
print("Shuffle DB state")
|
||||||
|
|
@ -664,6 +681,11 @@ class Shuffler(object):
|
||||||
print("Error: Writing iPod database failed.")
|
print("Error: Writing iPod database failed.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
for path,seen in self.speakable.items():
|
||||||
|
if not seen:
|
||||||
|
#print ('delete: {}'.format(path))
|
||||||
|
os.remove(path)
|
||||||
|
|
||||||
print("Database written successfully:")
|
print("Database written successfully:")
|
||||||
print("Tracks", len(self.tracks))
|
print("Tracks", len(self.tracks))
|
||||||
print("Albums", len(self.albums))
|
print("Albums", len(self.albums))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue