add deprecation warnings to the logic the new cache logic replaces.
parent
2f34df6603
commit
48e691a66f
|
@ -17,7 +17,12 @@ Cache handler - reads all the .dialog files (The default
|
|||
mycroft responses) and does a tts inference.
|
||||
It then saves the .wav files to mark1 device
|
||||
|
||||
* * * * D E P R E C A T E D * * * *
|
||||
THIS MODULE IS DEPRECATED IN FAVOR OF tts/cache.py. IT WILL BE REMOVED
|
||||
IN THE NEXT MAJOR RELEASE, 21.08
|
||||
|
||||
"""
|
||||
# TODO: remove in 21.08
|
||||
|
||||
import base64
|
||||
import glob
|
||||
|
@ -70,14 +75,15 @@ def generate_cache_text(cache_audio_dir, cache_text_file):
|
|||
if os.path.exists(each_path):
|
||||
write_cache_text(each_path, text_file)
|
||||
text_file.close()
|
||||
LOG.debug("Completed generating cache")
|
||||
LOG.info("Completed generating cache")
|
||||
else:
|
||||
LOG.debug("Cache file 'cache_text.txt' already exists")
|
||||
LOG.info("Cache file 'cache_text.txt' already exists")
|
||||
except Exception:
|
||||
LOG.exception("Could not open text file to write cache")
|
||||
|
||||
|
||||
def write_cache_text(cache_path, f):
|
||||
# TODO: remove in 21.08
|
||||
for file in glob.glob(cache_path + "/*.dialog"):
|
||||
try:
|
||||
with open(file, 'r') as fp:
|
||||
|
@ -109,6 +115,7 @@ def download_audio(cache_audio_dir, cache_text_file):
|
|||
cache_audio_dir (path): path to store .wav files
|
||||
cache_text_file (file): file containing the sentences
|
||||
"""
|
||||
# TODO: remove in 21.08
|
||||
if os.path.isfile(cache_text_file) and \
|
||||
os.path.exists(cache_audio_dir):
|
||||
if not os.listdir(cache_audio_dir):
|
||||
|
@ -137,16 +144,14 @@ def download_audio(cache_audio_dir, cache_text_file):
|
|||
with open(pho_file, "w") as cachefile:
|
||||
cachefile.write(json.dumps(vis)) # Mimic2
|
||||
# cachefile.write(str(vis)) # Mimic
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
# Skip this dialog and continue
|
||||
LOG.error("Unable to get pre-loaded cache "
|
||||
"due to ({})".format(repr(e)))
|
||||
LOG.exception("Unable to get pre-loaded cache")
|
||||
|
||||
LOG.debug("Completed getting cache for {}".format(TTS))
|
||||
LOG.info("Completed getting cache for {}".format(TTS))
|
||||
|
||||
else:
|
||||
LOG.debug("Pre-loaded cache for {} already exists".
|
||||
format(TTS))
|
||||
LOG.info("Pre-loaded cache for {} already exists".format(TTS))
|
||||
else:
|
||||
missing_path = cache_text_file if not \
|
||||
os.path.isfile(cache_text_file)\
|
||||
|
@ -163,21 +168,23 @@ def copy_cache(cache_audio_dir):
|
|||
Args:
|
||||
cache_audio_dir (path): path containing .wav files
|
||||
"""
|
||||
# TODO: remove in 21.08
|
||||
if os.path.exists(cache_audio_dir):
|
||||
# get tmp directory where tts cache is stored
|
||||
dest = util.get_cache_directory('tts/' + 'Mimic2')
|
||||
files = os.listdir(cache_audio_dir)
|
||||
for f in files:
|
||||
shutil.copy2(os.path.join(cache_audio_dir, f), dest)
|
||||
LOG.debug("Copied all pre-loaded cache for {} to {}"
|
||||
.format(TTS, dest))
|
||||
LOG.info(
|
||||
"Copied all pre-loaded cache for {} to {}".format(TTS, dest))
|
||||
else:
|
||||
LOG.debug("No Source directory for {} pre-loaded cache"
|
||||
.format(TTS))
|
||||
LOG.info(
|
||||
"No Source directory for {} pre-loaded cache".format(TTS))
|
||||
|
||||
|
||||
# Start here
|
||||
def main(cache_audio_dir):
|
||||
# TODO: remove in 21.08
|
||||
# Path where cache is stored and not cleared on reboot/TTS change
|
||||
if cache_audio_dir:
|
||||
if not os.path.exists(cache_audio_dir):
|
||||
|
|
Loading…
Reference in New Issue