diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0665084 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,111 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +This changlog uses the [ISO 8601 date format](https://www.iso.org/iso-8601-date-and-time-format.html) of (YYYY-MM-DD). + +## [Unreleased] + +## [1.5.1] - 2021-06-05 + +### Changed + +* Moved Changelog from Readme to Changelog.md file + +### Fixed + +* Fix TypeError when reading playlist files [#50](https://github.com/nims11/IPod-Shuffle-4g/pull/50) + +## [1.5.0] - 2020-06-10 + +### Changed + +* Port Script to Python3 +* Mutagen support is now optional + +## [1.4.0] - 2016-08-28 + +### Added + +* Added optional `--verbose` output +* Added files to `extras` folder +* Added shortcut parameters (`-p`, `-t`, `-d`, etc.) + +### Changed + +* Renamed `--voiceover` to `--track-voiceover` +* Renamed script from `shuffle.py` to `ipod-shuffle-4g.py` +* Ignore hidden filenames +* Do not force playlist voiceover with auto playlists + +### Fixed + +* Catch "no space left" error [#30](https://github.com/nims11/IPod-Shuffle-4g/issues/30) +* Fix UnicodeEncodeError for non-ascii playlist names [#35](https://github.com/nims11/IPod-Shuffle-4g/issues/35) + +## [1.3.0] - 2016-06-08 + +### Added + +* Directory based auto playlist building (`--auto-dir-playlists`) [#13](https://github.com/nims11/IPod-Shuffle-4g/issues/13) +* ID3 tags based auto playlist building (`--auto-id3-playlists`) +* Added short program description +* Differentiate track and playlist voiceover [#26](https://github.com/nims11/IPod-Shuffle-4g/issues/26) + +### Changed + +* Voiceover disabled by default [#26](https://github.com/nims11/IPod-Shuffle-4g/issues/26) (Playlist voiceover enabled with auto playlist generation) + + +### Fixed + +* Fix hyphen in filename [#4](https://github.com/nims11/IPod-Shuffle-4g/issues/4) +* Fixed mutagen bug [#5](https://github.com/nims11/IPod-Shuffle-4g/issues/5) + +## [1.2.0] - 2016-02-04 + +### Added + +* Added Path help entry +* Added MIT License +* Added this changelog + +### Changed + +* Skip existing voiceover files with the same name (e.g. "Track 1.mp3") +* Made help message lower case +* Improved Readme +* Improved docs + +### Fixed + +* Additional fixes from NicoHood +* Fixed "All Songs" and "Playlist N" sounds when voiceover is disabled [#17](https://github.com/nims11/IPod-Shuffle-4g/issues/17) +* Better handle broken playlist paths [#16](https://github.com/nims11/IPod-Shuffle-4g/issues/16) +* Only use voiceover if dependencies are installed + +## [1.1.0] - 2016-01-23 + +### Added + +* Fixes from nims11 fork +* Option to disable voiceover +* Initialize the IPod Directory tree +* Using the `--rename-unicode` flag filenames with strange characters and different language are renamed which avoids the script to crash with a Unicode Error +* Other small fixes + +## [1.0.0] - 2012-10-17 + +### Added + +* Original release by ikelos + +[Unreleased]: https://github.com/nims11/IPod-Shuffle-4g/compare/1.5.1...HEAD +[1.5.1]: https://github.com/nims11/IPod-Shuffle-4g/compare/v1.5...1.5.1 +[1.5.0]: https://github.com/nims11/IPod-Shuffle-4g/compare/v1.4...v1.5 +[1.4.0]: https://github.com/nims11/IPod-Shuffle-4g/compare/v1.3...v1.4 +[1.3.0]: https://github.com/nims11/IPod-Shuffle-4g/compare/v1.2...v1.3 +[1.2.0]: https://github.com/nims11/IPod-Shuffle-4g/compare/v1.1...v1.2 +[1.1.0]: https://github.com/nims11/IPod-Shuffle-4g/compare/646b7def4c498c59b063e535a5b64695d8d87e6b...v1.1 +[1.0.0]: https://github.com/nims11/IPod-Shuffle-4g/commit/646b7def4c498c59b063e535a5b64695d8d87e6b diff --git a/README.md b/README.md index 89ad287..ba6c8c0 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Optional Voiceover support * [PicoSpeaker](http://picospeaker.tk/readme.php) * [RHVoice (master branch, 3e31edced402a08771d2c48c73213982cbe9333e)](https://github.com/Olga-Yakovleva/RHVoice) -- (Russian files only) * [SoX](http://sox.sourceforge.net) -- (Russian files) +* say (macOS) ##### Ubuntu @@ -143,57 +144,3 @@ Your IPod should work and play music again now. The original shuffle3db website went offline. This repository contains a copy of the information inside the `docs` folder. Original data can be found via [wayback machine](https://web.archive.org/web/20131016014401/http://shuffle3db.wikispaces.com/iTunesSD3gen). - - -# Version History - -``` -1.5 Release (09.06.2020) -* Port Script to Python3 -* Mutagen support is now optional - -1.4 Release (27.08.2016) -* Catch "no space left" error #30 -* Renamed --voiceover to --track-voiceover -* Added optional --verbose output -* Renamed script from shuffle.py to ipod-shuffle-4g.py -* Added files to `extras` folder -* Ignore hidden filenames -* Do not force playlist voiceover with auto playlists -* Added shortcut parameters (-p, -t, -d, etc.) -* Fix UnicodeEncodeError for non-ascii playlist names (#35) - -1.3 Release (08.06.2016) -* Directory based auto playlist building (--auto-dir-playlists) (#13) -* ID3 tags based auto playlist building (--auto-id3-playlists) -* Added short program description -* Fix hyphen in filename #4 -* Fixed mutagen bug #5 -* Voiceover disabled by default #26 (Playlist voiceover enabled with auto playlist generation) -* Differentiate track and playlist voiceover #26 - -1.2 Release (04.02.2016) -* Additional fixes from NicoHood -* Fixed "All Songs" and "Playlist N" sounds when voiceover is disabled #17 -* Better handle broken playlist paths #16 -* Skip existing voiceover files with the same name (e.g. "Track 1.mp3") -* Only use voiceover if dependencies are installed -* Added Path help entry -* Made help message lower case -* Improved Readme -* Improved docs -* Added MIT License -* Added this changelog - -1.1 Release (11.10.2013 - 23.01.2016) -* Fixes from nims11 fork -* Option to disable voiceover -* Initialize the IPod Directory tree -* Using the --rename-unicode flag - filenames with strange characters and different language are renamed - which avoids the script to crash with a Unicode Error -* Other small fixes - -1.0 Release (15.08.2012 - 17.10.2012) -* Original release by ikelos -``` diff --git a/ipod-shuffle-4g.py b/ipod-shuffle-4g.py index f3aca4d..8225a56 100755 --- a/ipod-shuffle-4g.py +++ b/ipod-shuffle-4g.py @@ -97,12 +97,19 @@ def group_tracks_by_id3_template(tracks, template): return sorted(grouped_tracks_dict.items()) class Text2Speech(object): - valid_tts = {'pico2wave': True, 'RHVoice': True, 'espeak': True} + valid_tts = {'pico2wave': True, 'RHVoice': True, 'espeak': True, 'say': True} @staticmethod def check_support(): voiceoverAvailable = False + # Check for macOS say voiceover + if not exec_exists_in_path("say"): + Text2Speech.valid_tts['say'] = False + print("Warning: macOS say not found, voicever won't be generated using it.") + else: + voiceoverAvailable = True + # Check for pico2wave voiceover if not exec_exists_in_path("pico2wave"): Text2Speech.valid_tts['pico2wave'] = False @@ -147,6 +154,8 @@ class Text2Speech(object): return True elif Text2Speech.espeak(out_wav_path, text): return True + elif Text2Speech.say(out_wav_path, text): + return True else: return False @@ -162,14 +171,21 @@ class Text2Speech(object): def pico2wave(out_wav_path, unicodetext): if not Text2Speech.valid_tts['pico2wave']: return False - subprocess.call(["pico2wave", "-l", "en-GB", "-w", out_wav_path, unicodetext]) + subprocess.call(["pico2wave", "-l", "en-GB", "-w", out_wav_path, '--', unicodetext]) + return True + + @staticmethod + def say(out_wav_path, unicodetext): + if not Text2Speech.valid_tts['say']: + return False + subprocess.call(["say", "-o", out_wav_path, '--data-format=LEI16', '--file-format=WAVE', '--', 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]) + subprocess.call(["espeak", "-v", "english_rp", "-s", "150", "-w", out_wav_path, '--', unicodetext]) return True @staticmethod @@ -464,7 +480,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.playlist_voiceover and (Text2Speech.valid_tts['pico2wave'] or Text2Speech.valid_tts['espeak']): + if self.playlist_voiceover and (Text2Speech.valid_tts['pico2wave'] or Text2Speech.valid_tts['espeak'] or Text2Speech.valid_tts['say']): self["dbid"] = hashlib.md5(b"masterlist").digest()[:8] self.text_to_speech("All songs", self["dbid"], True) self["listtype"] = 1 @@ -534,7 +550,7 @@ class Playlist(Record): text = os.path.splitext(os.path.basename(filename))[0] else: # Read the playlist file - with open(filename, 'rb') as f: + with open(filename, 'r', errors="replace") as f: data = f.readlines() extension = os.path.splitext(filename)[1].lower()