get_hash_memoized.py 432 B

123456789101112131415
  1. from tts_webui.bark.history_to_hash import history_to_hash
  2. def memoize(func, file_path):
  3. if not hasattr(memoize, "cache"):
  4. memoize.cache = {}
  5. if isinstance(file_path, dict):
  6. return func(file_path)
  7. if file_path not in memoize.cache:
  8. memoize.cache[file_path] = func(file_path)
  9. return memoize.cache[file_path]
  10. def get_hash_memoized(file_path):
  11. return memoize(history_to_hash, file_path)