Explorar o código

Small function verify file not empty

Unknown %!s(int64=8) %!d(string=hai) anos
pai
achega
7726ad449a
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      tts/voxygen/voxygen.py

+ 5 - 1
tts/voxygen/voxygen.py

@@ -58,7 +58,7 @@ def get_voice(voice, language):
 
 
 def get_audio(voice, text, file_path, cache):
-    if not cache or not os.path.exists(file_path) or os.path.getsize(file_path) == 0:
+    if not cache or not os.path.exists(file_path) or file_is_empty(file_path):
         payload = {
             "method": "redirect",
             "text": text.encode('utf8'),
@@ -126,6 +126,10 @@ def write_in_file(file_path, content):
         file_open.close()
 
 
+def file_is_empty(file_path):
+    return os.path.getsize(file_path) == 0
+
+
 def create_directory(cache_path):
     if not os.path.exists(cache_path):
         os.makedirs(cache_path)