поделал сайт, сделал orm-модели, requirements.txt

This commit is contained in:
2023-04-29 08:52:01 +07:00
parent 23a56ae0c7
commit 3ee35ae080
17 changed files with 556 additions and 90 deletions
+21
View File
@@ -0,0 +1,21 @@
import os
from typing import List, Dict, Any
def get_log(log_id: int) -> List[Dict[str, Any]]:
log_dir = os.path.join("static/logs", str(log_id))
return_dir = []
for dir_path, _, filenames in os.walk(log_dir):
if dir_path != log_dir:
audio_file = os.path.join(dir_path, "audio.ogg")
if not os.path.exists(audio_file):
audio_file = os.path.join(dir_path, "audio.wav")
text_file = os.path.join(dir_path, "yandex-text.txt")
if not os.path.exists(text_file):
text_file = os.path.join(dir_path, "google-text.txt")
try:
return_dir.append({"id": log_id, "audio_file": f"/{audio_file}",
"text": open(text_file).read().split("\n")})
except UnicodeDecodeError:
pass
return return_dir